Sometimes while debugging, I need to restart a service on a remote machine. Currently, I'm doing this via Remote Desktop. How can it be done from the command line on my local machine?
You can use the services console, clicking on the left hand side and then selecting the "Connect to another computer" option in the Action menu.
If you wish to use the command line only, you can use
sc \\machine stop <service>
You can use mmc:
- Start / Run. Type "mmc".
- File / Add/Remove Snap-in... Click "Add..."
- Find "Services" and click "Add"
- Select "Another computer:" and type the host name / IP address of the remote machine. Click Finish, Close, etc.
At that point you will be able to manage services as if they were on your local machine.
You can use System Internals PSEXEC command to remotely execute a net stop yourservice, then net start yourservice
Using command line, you can do this:
AT \\computername time "NET STOP servicename"
AT \\computername time "NET START servicename"
I would suggest you to have a look at RSHD
You do not need to bother for a client, Windows has it by default.
Well, if you have Visual Studio (I know it's in 2005, not sure about earlier versions though), you can add the remote machine to your "Server Explorer" tag. At that point, you'll have access to the SERVICES that are running, or can be ran, from that machine (as well as event logs, and queues, and a couple other interesting things).
One way would be to enable telnet server on the machin you want to control services on (add/remove windows components)
Open dos prompt
Type telnet yourmachineip/name
Log on
type net start &serviceName* e.g. w3svc
This will start IIS or you can use net stop to stop a service.
Depending on your setup you need to look at a way of securing the telnet connection as I think its unencrypted.
Several good solutions here. If you're still on Win2K and can't install anything on the remote computer, this also works:
Open the Computer Management Console (right click My Computer, choose Manage; open from Administrative Tools in the Start Menu; or open from the MMC using the snap-in).
Right click on your computer name and choose "Connect to Remote Computer"
Put in the computer name and credentials and you have full access to many admin functions including the services control panel.
来源:https://stackoverflow.com/questions/187836/how-do-i-restart-a-service-on-a-remote-machine-in-windows