On all the servers I am tasked with managing I define a scheduled task – allowing me to perform a timed unattended reboot of the system. Most of the time this works well – once in a blue moon it doesn’t reboot the server though!
The command line for the task is:
shutdown /r /t 30 /c "Scheduled Reboot task" /d p:0:0
Occasionally the task fails with an error code of
0x4f7. This means that the console session is logged on and in a locked state!
Long and the short of it – Make sure you completely log off any active administrative sessions on the server when you schedule the next run of the task!
Alternatively, modify the command to look like this:
shutdown /r /t 30 /c "Scheduled Reboot task" /d p:0:0 /f
The /f on the end forces a restart – it also forcefully closes any running applications in any logged-on session.