Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way I can automate the restart of the Microsoft SQL services? How do I automate the restart of a Windows server?

share|improve this question

migrated from Oct 12 '09 at 13:25

This question came from our site for professional and enthusiast programmers.

is this because reboots fix everything? re-starting sql server is not a good thing to do, since you loose all the data cached in memory, which is what helps performance – Nick Kavadias Oct 14 '09 at 7:42

For SQL Server (or in fact any Windows service) you can use the net stop <Service Name> and net start <Service Name> to stop/start the service.

The service name you must use is not the display name, it's the actual name. To get that, go to the services control panel and view the service properties. It is the highlighted section on the screenshot: alt text

For Windows itself the shutdown command works well. Can be run with the following switches (these are the common ones, there is a few more):

  • /r switch to reboot
  • /s to just shutdown
  • /g reboot and restart registered applications
  • /p for immediate effect - same as using /t 0
  • /f to force running applications to close
  • /m \\computername to be run from another machine.

Aside: I do worry why you want to reboot SQL/Windows on a regular basis - normally that should not be needed and this sounds like a hack for a more serious issue. If you are planning on doing this, please document it fully in your logs and even put comments in the batch file and maybe even a text file as to why. The reasoning for situations like this tend to be forgotten and in the future you may not need to do this - but will have forgotten why you are.

share|improve this answer

You could use shutdown /r /t 0 /c "Scheduled Reboot" /m \\computername from another Domain-Server. Or leave out the /m \\computername and let it run as a scheduled job on the server itself.

share|improve this answer

I'm using PowerOff. You can configure it to run as a service and to show a warning message if case a user is logged on.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.