Subscribe

Get the Network Administrators tool pack

Subscribe to our newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them.

Click Here to get your free tools

Recent Posts

Search

Archives

Schedule a reboot in Windows 2003

by Steve Wiseman on September 13, 2007 · 6 comments

in Windows


.

There is always one application…yes one application that you use all the time, and can’t afford to have it down for one minute during the day.

This same application is buggy and always has problems if it keeps running day after day. You need to reboot once in a while. Yes, and this means you need to stay late and wait until everyone leaves…and then reboot.

There is a simple solution to the problem…the shutdown command in windows 2003. It can shutdown or reboot your system from the command line, and will even allow you to specify reason codes for the shutdown. Here is the lowdown on its possible options:

Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c “comment”] [-d up:xx:yy]

No args Display this message (same as -?)
-i Display GUI interface, must be the first option
-l Log off (cannot be used with -m option)
-s Shutdown the computer
-r Shutdown and restart the computer
-a Abort a system shutdown
-m \\computername Remote computer to shutdown/restart/abort
-t xx Set timeout for shutdown to xx seconds
-c “comment” Shutdown comment (maximum of 127 characters)
-f Forces running applications to close without warning
-d [u][p]:xx:yy The reason code for the shutdown
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)


So, if I wanted to shutdown the machine at a specified time I could create a script with the following:

shutdown -r -f -c “Shutdown to refresh buggy program”

The -f makes sure no application can keep the shutdown from happening, and the -c allows me to add a comment in the event log. The -r tells it to reboot.

Now I have saved this as RebootDaily.bat (Under the windows folder)

Lets schedule it to run daily at 3am. Open the control panel and double click on the “Scheduled Tasks”, and browse for the batch file that we just saved.

Schedule Reboot Daily

Click next, and set the time you want the reboot to start. If you have any backup jobs I would make sure the job time is far from your reboot.

Schedule Reboot 3AM

Click next and set the user account that will be used for the reboot. I suggest setting up a separate account with specific permissions for this task. That way you can slightly relax your password change policy – and lock it down so it can’t do much but reboot the system. Otherwise you will need to make sure you update this task each time the administrator password is changed.

Schedule Reboot Password

Click next, and then finish. Your reboot has been scheduled. Just makes sure it works by manually running it once.

Now your buggy application can get a fresh start every day.

One more thing…Subscribe to my newsletter and get 11 free network administrator tools, plus a 30 page user guide so you can get the most out of them. Click Here to get your free tools

Related Articles:

{ 6 comments… read them below or add one }

1 Benjamin Tessier September 21, 2010 at 3:53 pm

I tried exactly the steps you laid out for an automatic server reboot. The script runs but the server doesn’t shut down. Am I missing something?

2 Mridul September 28, 2010 at 5:28 pm

I second that, the script ran for a second and that was it. I have remote logged into the machine which I intend to shutdown. Could you please help?

3 Brian Harper March 28, 2011 at 2:11 pm

This does not work because of incorrect syntax. Duh….

use this –

shutdown /r /f /c “Shutdown to refresh buggy program”

4 Pat November 18, 2011 at 2:58 pm

This worked perfectly for me. It’s interesting that it’s so similiar to the UNIX shutdown command too.

5 Ron K December 11, 2011 at 7:40 am

The script works fine as is.

Once saved, right-click and select Edit, if the quotes are not there, manually put them back where they belong.

Copying and pasting, can result in unexpected behavior 🙂

6 Andy April 20, 2012 at 7:55 am

To get this to work I just shortened the script.

shutdown -r -f

Leave a Comment

Category Links - Windows Forum - Exchange Forum