Assistance with a script please
I have a script that's purpose is to list the services running on multiple servers from a text file. The problem I am having is when I try to run the script I get the following error:
"C:\WINDOWS\system32\ListServices.vbs(1,32)
Microsoft VBScript compilation error: Expected end of statement: cscript ListServices.vbs.Const INPUT_FILE_NAME="C:\Scripts\Computers.txt"
I am not sure what it is looking for, apparently the offending item is character 32 which appears to be a space, I am not sure. I have googled and searched and can't find anything to see to help me so this is my last resort. The script is below:
cscript ListServices.vbs.Const INPUT_FILE_NAME="C:\Scripts\Computers.txt" Const FOR_READING = 1
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile(INPUT_FILE_NAME, FOR_READING)
strComputers = objFile.ReadAll
objFile.Close
arrComputers = Split(strComputers, vbCrLf)
For Each strComputer In arrComputers
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colRunningServices = objWMIService.ExecQuery _
("Select * from Win32_Service")
For Each objService in colRunningServices
Wscript.Echo objService.DisplayName & vbTab & objService.State
Next
Next
Please let me know if you need any further information and I also appreciate any assistance with this in advance.
Thank You,
Micah
|