I need to parse a list of processes in a text file to run the check, and spit out a non zero exit code if any of the processes listed in the text file are running. Can be a csv file too, though am assuming a .ini with a process listed on each line would be easiest. Any help is greatly appreciated! I have zero VB scripting experience, but the boss doesn't care about that!
I've got this script that checks for a hard coded process, assuming I can build off this...
' List the processes Running on a Computer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = " & _
"'notepad.exe'")
If colProcesses.Count = 0 Then
Wscript.Echo "No scripts are running."
Else
For Each objProcess in colProcesses
Wscript.Echo objProcess.CommandLine
Next
End If
I've got this script that checks for a hard coded process, assuming I can build off this...
' List the processes Running on a Computer
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colProcesses = objWMIService.ExecQuery _
("SELECT * FROM Win32_Process WHERE Name = " & _
"'notepad.exe'")
If colProcesses.Count = 0 Then
Wscript.Echo "No scripts are running."
Else
For Each objProcess in colProcesses
Wscript.Echo objProcess.CommandLine
Next
End If