Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBS HELP NEEDED

Status
Not open for further replies.

trytofixalot

Technical User
Jun 28, 2010
8
GB
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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top