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>
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).
Agreed with the Connect to Another computer option. I've used the Computer Management MMC to do similar stuff in the past.
NET START SERVICENAME is the syntax for command line, but I don't see a way to do target a remote machine.
This sounds like a job for PowerShell.
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
I don't think enabling telnet is a good way to administer any server, let alone a Windows server. You're just opening a security hole.
The services console is definitely a more sane solution,
Using command line, you can do this:
AT \\computername time "NET STOP servicename"
AT \\computername time "NET START servicename"
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.