News, Product Information, and Tips
Check out our free utlities in the downloads section

Remote Administration



Remote Administration For Windows. Easy remote access of Windows 7, XP, 2008, 2000, and Vista Computers

Click here to find out more

Create Outlook Profiles



No more setup wizards in Outlook. Setup Outlook Profiles automatically from the command line

Click here to find out more

Network Administrator



Reboot Hundreds of computers, disable flash drives, deploy power managements settings.

Click here to get your free copy of Network Administrator. Over 25 plugins to make your life easier

USB Disabler



Disable Flash Drives for specific users, or only allow specific drives.

Click here for your free trial

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.

Like this article? Then sign up for my newsletter to get free tips and software sent right to your inbox once a week. Like you, I hate spam – I will never spam, or sell your email address.

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