trytofixalot
Technical User
Hi, can someone provide some guidance on this please.
I have a vbs that parses a comma seperated text file looking for my computername, and if exists writes to regisry values, however i cannot get the loop function to work. The script currently only works if my computername is on the top of the list in the text file. Thanks !
An example of the mylist.txt files is -
computername123,Engineering,London
The VBS is -
option explicit
dim wsh, fso, inputfile, machinename, inputline, linetosplit, strhost, strbu, strseg
set wsh = createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set inputfile = fso.openTextFile("C:\Users\username\Documents\Tools and Scripts\BUSeg Script\mylist.txt",1, FALSE)
machinename = Wsh.ExpandEnvironmentStrings("%computername%")
Do While Not (InputFile.atEndOfStream)
inputline = inputfile.readline
linetosplit = split(inputline,",")
strhost = linetosplit(0)
strbu = linetosplit(1)
strseg = linetosplit(2)
if UCASE(strhost) = UCASE(machinename) then
wsh.regwrite "HKLM\Software\MyCompany\Application\Business",strbu
wsh.regwrite "HKLM\Software\MyCompany\Application\Segment",strseg
else
wsh.regwrite "HKLM\Software\MyCompany\Application\Business","Unknown"
wsh.regwrite "HKLM\Software\MyCompany\Application\Segment","Unknown"
end if
loop
I have a vbs that parses a comma seperated text file looking for my computername, and if exists writes to regisry values, however i cannot get the loop function to work. The script currently only works if my computername is on the top of the list in the text file. Thanks !
An example of the mylist.txt files is -
computername123,Engineering,London
The VBS is -
option explicit
dim wsh, fso, inputfile, machinename, inputline, linetosplit, strhost, strbu, strseg
set wsh = createobject("wscript.shell")
Set fso = CreateObject("Scripting.FileSystemObject")
Set inputfile = fso.openTextFile("C:\Users\username\Documents\Tools and Scripts\BUSeg Script\mylist.txt",1, FALSE)
machinename = Wsh.ExpandEnvironmentStrings("%computername%")
Do While Not (InputFile.atEndOfStream)
inputline = inputfile.readline
linetosplit = split(inputline,",")
strhost = linetosplit(0)
strbu = linetosplit(1)
strseg = linetosplit(2)
if UCASE(strhost) = UCASE(machinename) then
wsh.regwrite "HKLM\Software\MyCompany\Application\Business",strbu
wsh.regwrite "HKLM\Software\MyCompany\Application\Segment",strseg
else
wsh.regwrite "HKLM\Software\MyCompany\Application\Business","Unknown"
wsh.regwrite "HKLM\Software\MyCompany\Application\Segment","Unknown"
end if
loop