Trigger an automatic shutdown from command prompt on Windows

You can shutdown your Windows machine from the command prompt – and also delay the shutdown time for say, 5 minutes, from when you execute the command.

I’d say this feature has two main uses:

  1. You want to schedule your computer to shutdown after a certain amount of time. Maybe it’s finishing a task, and needs an extra 10 minutes before you shutdown? But you have to leave NOW.
  2. Or, to play a cruel prank on your friend. (use at your own peril – I cannot be held responsible!)

You can also cancel Windows from shutting down when triggered from the command prompt, which you’ll see how to do below – so please feel free to try these as you go along, and just cancel them at any time.

Firstly, open your windows command terminal. Keyboard shortcut: Windows button + R. Then type in cmd, and press Enter:

run command prompt shortcut

Bringing us here:

command window

Now, to do the standard shutdown, which will perform the shutdown in 60 seconds, we type shutdown -s:

default shutdown cmd line

Press Enter, and you'll be notified of the automatic shutdown in 60 seconds! The alert notification will appear:

automatic shutdown notice from cmd prompt

Don't worry, you can cancel your computer from shutting down, by typing shutdown /a into the command prompt:

cancel windows shutdown cmd line

You will be notified of the cancellation. With something like the following:

windows shutdown cancel

You can also cancel the shutdown in the start menu, by again typing shutdown /a. Like so:

stop windows shutdown

Schedule a time to wait before shutting down using command prompt

You can add another option to the shutdown call inside of command prompt to provide a time delay before shutting down the computer. To do so, you need to type shutdown -s -t 120. That will tell Windows to wait 120 seconds before shutting down:

schedule shutdown windows command

You'll receive a similar looking notice as below:

scheduled shutdown notice

I will of course cancel this command with shutdown /a afterwards!

How to add a custom message to the notice box on shutdown with command prompt

And finally, here's a technique to add a custom message to the notification box. Maybe "HAHAHA LMAO!!1!" if it's a prank on your unlucky friend!?

For the above example, you would type shutdown -s -t 60 -c "HAHAHA LMAO!!1!". Like so:

add message to shutdown with command prompt

And after pressing enter, you'll get an evil notice message:

custom shutdown message windows


With great power, comes great responsibility. Remember to save your work and enjoy the power of shutting down Windows directly from the command prompt.

Stay up-to-date...

@codechewing is where we always announce the release of any new guide - follow us to keep updated.

Join in

Code Chewing Twitter