I'm looking for a way to restart Windows services

  • from batch scripts (preferrably CMD)
  • on a remote machine
  • using a different account than the one the script is running as

Looking at the parts that I already have in place, the missing bits are:

  • runas does not provide a way to specify the password, so I can't call the remote machine with the appropriate account
  • There seems to be no command line equivalent of the restart button in services.msc, so I would have to implement this myself by polling sc query

Are there any standard solutions to these issues?


There is a way to restart services by using sc stop and sc start or net stop net start, if using net, then you have to use real name of service (as in sc query).

For remote connection to Windows and run batch commands under another use, you can use PsExec from systeminternals.

  • Thanks for the psexec hint, that was the missing bit. I can now run the start/stop command directly on the remote machine, e.g. psexec \\servername -u username -p password sc stop ServiceName – themel Dec 3 '12 at 20:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.