To Stop a Service:
-------------------
strServiceName = "CVPND"
Set a= GetObject("winmgmts:\\" & strComputer)
Set b = a.ExecQuery("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each c in b
c.StopService()
Next
To Start a Service:
-------------------
strServiceName = "CVPND"
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\.\root\cimv2")
Set colListOfServices = objWMIService.ExecQuery ("Select * from Win32_Service Where Name ='" & strServiceName & "'")
For Each objService in colListOfServices
objService.StartService()
Next
***********************************************
No comments:
Post a Comment