1

We have a server that is on the same LAN as my work computer. I know you can use "net stop" and "net start" in a batch file to restart a service on the local machine, but is it possible to do that for a remote machine?

I know you can use \computer to browse a networked machine, for example, so is there some syntax that would be something like \computer net stop service or so on?

Right now I have to Remote Desktop into the machine, restart the service, then log off, which is a hassle.

Danny Forche
  • 29
  • 1
  • 5
  • possible duplicate of http://stackoverflow.com/questions/266389/simplest-way-to-restart-service-on-a-remote-computer – alexbuisson Jul 12 '13 at 16:50

2 Answers2

1

Create a Desktop shortcut in the cmd to run enter :

sc \\server stop service

sc is the service management tool server is your remote server name or IP and finally service is the name of the service you target

alexbuisson
  • 7,699
  • 3
  • 31
  • 44
  • Thanks. Is it possible to use runas.exe to do this? I have to run it as a network admin account, and my regular workstation is not running as that. For things such as SQL Server Management, I can make a runas shortcut, but I keep getting the help text instead of any action when I try the command. I'm using: C:\Windows\System32\runas.exe /savecred /user:[user] "sc.exe \\[server] stop "[service name]"" – Danny Forche Jul 15 '13 at 13:18
  • I figured it out - for anyone else wondering: you can use this command: C:\Windows\System32\runas.exe /savecred /user:[domain\user] "C:\windows\system32\cmd.exe /c C:\Test.bat" Where your batch file with the sc \\server stop service is in C:\Test.bat. (You can move that around obviously) – Danny Forche Jul 15 '13 at 20:05
0

I figured it out - for anyone else wondering: you can use this command:

C:\Windows\System32\runas.exe /savecred /user:[domain\user] "C:\windows\system32\cmd.exe /c C:\Test.bat" Where your batch file with the sc \server stop service is in C:\Test.bat. (You can move that around obviously)

Danny Forche
  • 29
  • 1
  • 5