Looks like the closest you can get in XP is QueryServiceStatusEx (single service) or EnumServicesStatusEx (multiple services).
To avoid repeatedly calling either of these, some recommend a WMI setup, querying Win32_Service
's state
property. See the bottom of this thread for more details.
The following is a (basic) WMI script to monitor the alerter service's status:
strComputer = "."
Set objSWbemServices = GetObject("winmgmts:" &_
"{impersonationLevel=impersonate}!" &_
"" & strComputer & "
ootcimv2")
Set objEventSource = objSWbemServices.ExecNotificationQuery( _
"SELECT * FROM __InstanceModificationEvent " &_
"WITHIN 10 " &_
"WHERE TargetInstance " &_
"ISA 'Win32_Service' " &_
"AND TargetInstance.Name = 'alerter'")
Set objEventObject = objEventSource.NextEvent()
Wscript.Echo "The status of the alerter service just changed."
The above, and additional examples, may be found on this TechNet page.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…