Thursday, November 13, 2008

Start Stop Restart a windows service remotely

Start Stop Restart a windows service remotely

Find the service name
You'll need the exact service name, which is stored in the registry. An easy way to find it is to enumerate all the services on the box, and then usually you can pick it out from there.

Method 1:
$ sc.exe \\server_name getkeyname "The_Service_Display_Name"

Method 2:
$ sc.exe \\server_name query | less
That will be a long list, so pipe it to less and page through it. That will list an entry for each service, like so:

Stopping the service

$ sc.exe \\server_name stop service_name

Note: PsTools from SysInternals comes with psservice.exe which has a “restart” command.

No comments: