1.

Solve : Remote stop service?

Answer»

Hi All,
I would like to stop a service from one machine onto another machine. I remember in VBS I could impersonate a user and get the service to stop.

Anyone have any IDEAS as to how to get this done?

Thanks
This should do it:

Code: [Select]strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colServiceList = objWMIService.ExecQuery _
("Select * from Win32_Service where Name='stisvc'")

For Each objService in colServiceList
errReturn = objService.StopService()
Next

CHANGE the VALUE of strComputer to the name of your remote computer. I used stisvc as the service name. Change accordingly.

You can execute services.msc from the run box to get the names of the services. Be sure to use the service name and not the display name.

Good luck. GREAT! Thanks for your help!



Discussion

No Comment Found