I would like to schedule a one-time server restart, e.g. to finish installing updates early in the morning. How can I do this from the command line on Windows 2012?
On Windows 2008, I would have used the
at 2am shutdown -r -f -c "restart"
and taken the rest of the afternoon off.
But on Windows 2012, running this command tells me that
The AT command has been deprecated. Please use schtasks.exe instead.
So the equivalent command with schtasks.exe might be
schtasks /create /sc once /tn restart /tr "shutdown - r -f ""restart""" /st 02:00
Apart from being very forgettable, this command has another important downside: it schedules the task for 2am today—not much use unless I'm awake at 1am to run it.
According to the help for schtasks.exe, the
/sd switch for setting the start date is not applicable with
/sc once. So even if I wanted to type out tomorrow's date in mm/dd/yyyy format—and I don't—I can't do this.
The only possible solution I've found is here, where Kevin Traas suggests creating batch file to create a scheduled task just before midnight that waits for a couple of minutes and then creates another scheduled task to run the command that you actually want to run. Clever, but nowhere near as convenient as