I've been trying to get Server 2008 R2 to reboot after everyone is gone from work, to get its updates installed, but what I've been trying apparently isn't working.

I have a "reboot.bat" in C:/ that contains:

shutdown –r –f –t 5

The task is scheduled for 11:00PM, but when I come in the next day, it says "Last Run Result: (0x1)." and the server hasn't restarted.

Is there a better way to do this? Hopefully one that works...?

  • 1
    Yup - aside from anything else, you've got your syntax wrong, as cheekaleak shows you below. Slashes, not dashes - mostly standard for Windows executables.
    – mfinni
    Commented Jun 22, 2012 at 18:02
  • 1
    It makes sense to try running a batch file from the command line to make sure it works before scheduling it and keeping your fingers crossed it runs as scheduled.
    – dimitri.p
    Commented Jun 22, 2012 at 20:43

2 Answers 2


yes, set your scheduled task to run whether user is logged on or not and is set to run with highest privledges. For the Actions section, set the action to "start a program" with C:\Windows\System32\shutdown.exe and then /r /f /t 5 as the arguments.

Make sure the account credentials used for the task have Log on as Batch Job rights.

  • I already have "Run whether user is logged in or not" and "Run with highest privileges" set. I'll try the shutdown.exe instead of my reboot.bat though. I'm running it as the Domain Admin, so I assume it has the Batch Job rights?
    – David
    Commented Jun 22, 2012 at 17:53
  • That would be dependent on how your policies are setup, so you may not. If you open an elevated command prompt and run "rsop" drill down to: Computer Configuration> Policies> Windows Settings> Security Settings> Local Policies> User Rights Assignment; and check if the Domain Admin group is listed under "Log on as batch job".
    – HostBits
    Commented Jun 22, 2012 at 18:00
  • That is it, thanks. Hopefully I won't have to report back come Monday!
    – David
    Commented Jun 22, 2012 at 18:09

Is this a once off? If so you can probably get away with just the shutdown command; no scheduled task needed.

Eg, to restart in 12 hrs (or 43200 seconds):

shutdown -r -t 43200

Unfortunately, this doesn't work on all versions; Server 2003 and Vista restrict you to 600 seconds (10 minutes). For all versions since then and, strangely, also XP, the maximum is 315359999 seconds (~10 years).

This is contra to Microsoft's docs on the command which state the maximum delay is 600 seconds all the way though to Server 2012.

  • In response to the time limit threshold; in the shutdown GUI (shutdown -i) on later OSs still, there is a maximum input limit of 600s. cmd line must not enforce that.
    – MaCuban
    Commented Oct 28, 2015 at 15:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .