In a previous article, I showed you how to view and kill processes on remote Windows computers.
One drawback to killing processes on a remote computer, is if the process was started by a service, once it's killed it's no longer running anymore.
NOTE: If you are unfamiliar with Windows Services, see the following article on services.
Being able to restart the service again, remotely, may be necessary with out rebooting the remote computer, especially if the service is needed by the user.
One of the best utilities to accomplish this, is to use Sysinternals PsService tool.
PsService is a service viewer and controller that allows you to connect to a remote system and stop or start services. Two things that make this utility great - it's free and requires no installation at all (yeah!).
But before you can connect to a remote system using PsService, you need to make sure ports 445 and 139 are open on the remote computer. This means, if the computer is running a firewall, or a firewall exists between your computer and the remote computer, those ports need to be open.
Also you need to use an account that has administration rights on the remote computer, that can stop and start services.
To use PsService, first download it from Microsoft's Sysinternals site (PsServices is bundled with the PsTools suite).
Next, unzip PsTools.zip and you should see the psservice.exe executable.
Now, PsService is easy to use. Say you just killed the spooler process on a remote computer because of a printing problem and need to start the spooler service.
First, open a command prompt on your computer (click Start \ Run and enter cmd in the run box) then change to the directory where you copied the psservice executable, and enter the following command at the prompt:
NOTE: The first time you use PsService, you must agree to the license agreement. To do so, just click on the Agree button.
psservice.exe \\rcomputer -u mike -p 123456 start spooler
Where:
\\rcomputer - is the name of the remote computer.
-u mike -p 123456 - is the username and password of the account that has administration rights on the remote computer.
start spooler - is the command to start the service named spooler.
After executing the command and starting the service, PsService will display the results and the state of the service, which in this case is running.
PsService can also stop services using the following command:
psservice.exe \\rcomputer -u mike -p 123456 stop spooler
One nice feature with PsService is the capability to query the list of services on the remote computer. This can be useful if need to find the service before killing a process.
To query the list of service, just use the following command:
psservice.exe \\rcomputer -u mike -p 123456 query
If you have not noticed, the list scrolls by in a hurry. To make it stop before scrolling off the screen, you can use the more command as follows:
psservice.exe \\rcomputer -u mike -p 123456 query |more
This will allow you to page through the list by pressing the space bar. If you want to quit before the end of the list, just press CTRL+C.
PsService is a great utility to add to your toolbox. One drawback to the tool that I have found is that it can be a little quirky at times. I find that it works well in a Windows domain environment or even when computers are in a workgroup. While other times it has trouble connecting.
Either way, it's a time saver that does not require any installation of remote control software.
Comments on How To Stop And Start Services On Remote Windows Computers
clonec @ 3:07 am
Nice Posting
but, Not work for Windows7 remote host.
D:\PsTools>PsService.exe \\T02 -u T02 -p mypass stop spooler
PsService v2.24 - Service information and configuration utility
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - http://www.sysinternals.com
Error querying services on \\T02:
Access is denied.
Error opening spooler on \\T02:
Access is denied.
User T02 is Administrator group.
Any sollution ???
Jinx Dojo @ 9:27 am
I'm running Windows XP and I receive the same error as clonec. I've searched all over for a resolution. I have port 445 open (necessary for remote administration). I enabled the "remote administration exception" in Windows Firewall. I even disabled Windows Firewall entirely. What on earth needs to be done to either give the appropriate permissions or to get PSServices.exe to operate successfully?
Shameer @ 7:48 am
Hi,
When i tried to use this for restarting a Jetform service hosted in the Remote computer (WIN2003) it throws Error as the service doesnot exist as installed service.
Kindly help me
Regards,
Shameer
Ньютон @ 7:29 am
This is still true for Windovs7?