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...?
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.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):
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.