I have a script to check file versions, but I am havig problems with the loop. make a few edits to it and it will loop, but only to the first line of the text file. Then it runs untill I kill it, or I can make a few other changes and get an error that I used a loop without a DO command. I can't figure that one out since the DO command is on line 13 of the script.
Can someone take a look at this for me and see what I am overlooking. I'm sure it is something simple, but I'm not seeing because I've been looking at the screen for two many hours.
---------------------------------------------------------------
' =====================================================
' Code to read computer name from a text file
' =====================================================
On Error Resume Next
Const ForReading = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile("c:\scripts\WSH.txt", ForReading)
Do Until objTextFile.AtEndOfStream
strComputer = objTextFile.ReadLine
' =========================================================
' Code to check file version on remote machines
' =========================================================
Set objWMIService = GetObject _
("winmgmts:\\" & strComputer & "\root\cimv2")
Set colFiles = objWMIService.ExecQuery _
("SELECT * FROM CIM_DataFile WHERE Name = 'C:\\winnt\\system32\\wscript.exe'")
For Each objFile in colFiles
' =======================================================
' Code to write output to a file
' =======================================================
Const ForAppending = 8
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objTextFile = objFSO.OpenTextFile _
("c:\scripts\output.txt", ForAppending, True)
objTextFile.WriteLine("Computer: " & strComputer & vbTab & _
"WSH Version: " & objFile.Version)
Next
' =======================================================
' End
' =======================================================
Loop
objTextFile.Close
WScript.Echo "Script Complete! Check in C:\scripts\output.txt for your results."
---------------------------------------------------------------
I have a folder created with the output.txt and wsh.txt in it.