Script which checks if a process is running on a network machine.
listPath = ScriptPath & "list.txt"
processname = "PROCESS NAME HERE"
query = "SELECT * FROM Win32_Process WHERE Name='" & processname & "'"
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.OpenTextFile(listPath)
Do Until f.AtEndOfStream
skipServer = False
server = f.ReadLine
On Error Resume Next
Set wmi = GetObject("winmgmts://" & server &"/root/cimv2")
If Err Then
If Err.Number = 462 Then
reportHTML.WriteLine "<font color=green> - Host is switched off</font> <br/>"
skipServer = True
else
reportHTML.WriteLine "<font color=red> Error " & Err.Number & " connecting to " & server & " : " & Err.Description & "</font><br/>"
On Error Goto 0
skipServer = True
End If
End If
On Error Goto 0
If Not skipServer Then
found = false
For Each process in wmi.ExecQuery(query)
found = true
Exit For
Next
If not found then
reportHTML.WriteLine "<font color=green> - is not running</font> <br/>"
else
reportHTML.WriteLine "<font color=red> - IS RUNNING </font><br/>"
end if
End If
Loop
f.Close