Windows: Shutdown with timeout and abort a timed shutdown
It is possible to abort a shutdown in Windows provided that the shutdown command had a timeout associated with it. Restarts triggered by Windows updates usually have a timeout. Also, if you are invoking shutdown from the command line you have the option of setting a timeout for the shutdown. I will explain where this can be useful later in the article. Either way, the abort command must be issued before the timeout is over.
Delayed Shutdown with a timeout
As mentioned earlier, if you are shutting down the computer from the command line, you can set a timeout for the shutdown. The shutdown will happen only if you don’t abort the shutdown within the timeout period.
Here is the command:-
1shutdown /s /t 300
Here the /s is for choosing the shutdown option, as opposed to hibernate, restart, etc. The /t is for the timeout; the timeout duration is specified in seconds. So this command would lead to Windows waiting 5 minutes before the shutdown.
Where is this useful?
Running this command from the console might seem like a useless thing to do. Why would you want to shut down the computer 5 minutes later instead of doing it immediately? But, this command is useful if you combine it with other, possibly long-running commands. For example, you may want to shut down your computer after performing a backup. Here you could chain the two commands. Here is an example:-
1backup.bat && shutdown /s /t 300
In the above example, the shutdown command is run after the backup command is finished. If you have changed your mind about the shutdown by then, the timeout gives you time to abort the shutdown. Many GUI programs which give the user the option to shut down the computer after finishing some task use the timeout version of the shutdown command.
How to abort a Shutdown
- From the Start Menu open cmd
- Type
shutdown /a
and hit enter
You should see a message like the one below, however, this might be different depending on your version of Windows.