Here is a script that will monitor a service. If the service is “stopped” it will be restarted and a event will be generated in the local event viewer. You can create a rule to collect event ID 4 and/or event source WSH, then you will get information about it in Operators Console.
strServiceName = "Alerter"strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where Name = '" & strServiceName & "'")
For Each objService in colListOfServices
If objService.State = "Stopped" Then
objService.StartService()Const EVEN_INFORMATION = 4
Set objShell = CreateObject("Wscript.Shell")
objShell.LogEvent 4, strServiceName & " has been restarted."
End If
Next
[…] that restarts services at my webpage. If you want to you can copy it, for example this script http://contoso.se/blog/?p=61 —– Regards Anders Bengtsson Microsoft MVP – MOM http://www.contoso.se AN> Hi, AN> […]
[…] Making MOM alert dependent on service Hi Vijay, Take a look at this script, http://contoso.se/blog/?p=61 , it check a service. Add a if service running, then run your script, else not. Something like […]