Hello,

usualy the WMI Service Sensor is Monitoring if a Service is running. In our Case we go some Service, that have to be stopped. Is it possible to use the WMI Service Sensor the other way and only showing warnings and errors, if these Services are running?

Thanks. :-)


Article Comments

Hi Martin

i know you asked about using WMI. But I use a custom sensor VBS Script I adapted to check if a process is running which shouldn't (in our case dropbox.exe) I am quite sure you can use this to check if the service is not running. regards Thomas

on error resume next

' Commandline Argument is process.exe
' ex: cscript getprocess.vbs explorer.exe
' **************************************
strComputer = "."

if isNull(WScript.Arguments.Item(0)) then
	wscript.echo "Process not given -> getprocess.vbs processname.exe"
	wscript.quit
else
	strProcess = WScript.Arguments.Item(0)	
end if

strComputer = WScript.Arguments.Item(1)


Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" _
    & strComputer & "\root\cimv2")

Set colItems = objWMIService.ExecQuery( _
    "Select * from Win32_Process WHERE name ='"&strProcess&"'")

if colItems.Count < 1 then	
	Wscript.Echo colItems.Count&":Ok" 
	Wscript.quit("0")
ELSE
	wscript.echo colItems.Count&":processes running"
	wscript.quit("1")
	
end if

Nov, 2015 - Permalink

Hi Thomas,

thank you. I'm not so familiar with VB, but I will try to figure out how to integrate your script and let you know the result. :-)

Regads Martin


Nov, 2015 - Permalink

Ahhh, Thomas.

It's the first time I used VB in PRTG and didn't saw the possibility, to simply add the name of EXE-File under "Parameter" of the Sensor. :-) It seems to run! :-D

Thank you!!! ;-)

Cheers Martin


Nov, 2015 - Permalink

@Martin Bitte gern geschehen ;)

cheers Thomas


Nov, 2015 - Permalink