I am trying to automatically start a service that is failing. Before I
can start the service, I need to verify that the service can be
stopped. I have the following code that tells me the state of all
services running that can be stopped. What I need to do is only check
if a particular service can be stopped, then if it can, kick off the
stop and restart of the service. I can stop and start, I just need to
fix the following code to check for a particular service.
strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer &
"\root\cimv2")
Set colServices = objWMIService.ExecQuery _
("Select * from Win32_Service Where AcceptStop = True")
For Each objService in colServices
Wscript.Echo objService.DisplayName
Next
Thanks