' Monitor service modification events
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colMonitorProcess = objWMIService.ExecNotificationQuery _
("SELECT * FROM __InstanceModificationEvent WITHIN 1" & _
"WHERE TargetInstance ISA 'Win32_Service'")
WScript.Echo "Waiting for service to be modified ..."
Set objLatestEvent = colMonitorProcess.NextEvent
Do
Set objLatestEvent = colMonitorProcess.NextEvent
Wscript.Echo VbCrLf & "Service Name: " & objLatestEvent.TargetInstance.Name
Wscript.Echo "Status: " & objLatestEvent.TargetInstance.State
Wscript.Echo "Startup Type: " & objLatestEvent.TargetInstance.StartMode
Wscript.Echo "Time: " & Now
Loop