trytofixalot
Technical User
Hi, I have created a vbs that parses a comma seperated txt file for my machine name which then writes 2 values to the regsisty. I cannot get the 'loop' function to work. the script only works if the computername is on the top of the list with thin text file. Can someone help me out pls.
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
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