When Nothing Else Works, Use the Command Prompt to Shut Down Windows

There are many ways to shut down a PC with a few keystrokes.

May 8, 2025 - 16:32
 0
When Nothing Else Works, Use the Command Prompt to Shut Down Windows

In an ideal world, you'd lead a long and happy life only ever shutting down and restarting your PC via the Start menu. Click the power icon, choose your option, and you're done. However, life doesn't always work out like we plan it, and sometimes you may need to trigger a restart or shutdown from the command prompt instead.

Maybe something is stopping the Start menu from working, or perhaps you find yourself on a screen where the Start menu isn't available. One of the scenarios where I use the command prompt to shut down Windows is when I'm in the initial setup phase for the operating system and don't want to complete it right away.

Command prompt
The shutdown command can turn off your PC on a timer. Credit: Lifehacker

You might also have loaded the command prompt interface to try and troubleshoot a problem that's stopping Windows from working—in which case you need to know how to power off or reboot your computer without pressing and holding the power button. (If you are having PC issues, see also this lesser-known emergency restart option.)

Using the command prompt

If you're completely new to the command prompt, it's the text-based interface hidden away in Windows, a remnant of the old days before computer operating systems had pointers and graphical user interfaces, and still useful for running a variety of low-level system operations.

Windows PowerShell
PowerShell doesn't look too different to the command prompt at first glance. Credit: Lifehacker

The command prompt is also accompanied by PowerShell, which is a more modern and feature-rich version of this interface. As far as these shutdown and restart commands are concerned, you can use either for the job, but if you ever need to run more advanced text commands, scripts, and automations, PowerShell is better set up to accommodate them.

You can launch either the command prompt or PowerShell from the Start menu: Just type the first few letters of either utility into the search box at the top to find them. There are various other options too, like right-clicking on the Start menu button and choosing Terminal, or by typing "cmd" into the search box on the taskbar and hitting Enter.

Using the "shutdown" command

The text command you need to either shut down or restart your Windows computer is 'shutdown'. If you type it into the command prompt or PowerShell and then hit Enter, you'll get a full description of shutdown, and all the ways you can use it (by the way, you can add "| more" to this or any command to see a page of text at a time).

Type "shutdown /s" to trigger a standard shutdown

The most basic flags you'll need are "shutdown /s" and "shutdown /r" to power off and restart your computer, respectively. In both cases you'll see a dialog box on screen telling you what's happening, and the action is taken in less than a minute. These commands will initiate a normal shutdown process, so you'll be prompted to save any unsaved work in your open programs that usually do that.

Command prompt
This will restart Windows and launch the advanced boot options screen. Credit: Lifehacker

Type "shutdown /s /f" to force a shutdown

To force all apps to close without any further prompting—perhaps if you need to make sure the shutdown or restart goes through without a hitch—add the "/f" to the end of your command (so, either "shutdown /s /f" for a shutdown or "shutdown /r /f" for a restart). You do this at your own risk though, with the risk of losing data that hasn't already been saved, and it's probably best left as a last resort.

Type "shutdown /r /o" to access advanced boot options

For troubleshooting purposes, the "shutdown /r /o" command is useful because it reboots your computer into the advanced boot options screen. That's the one that gives you access to features such as using a USB drive to recover your PC, running the built-in start-up repair utility, and rolling back recent updates to Windows. You can also get back to the command prompt from here without starting the operating system.

Cancel shutdown
The shutdown command can also be used to stop a shutdown. Credit: Lifehacker

Time your shutdown by adding "/t"

Another flag that can be useful is the "/t" flag followed by a space and a number. This puts the shutdown or the restart on a delay, giving you time to close apps or finish downloads. The number is the number of seconds Windows should wait, and it can go from 0 (instant) all the way up to 315360000—that's 10 years, if you were wondering. If the seconds are set to anything above zero, the "/f" flag is also applied.

Stop a shutdown with "shutdown /a"

One final one that you might find helpful: You can use "shutdown /a" to abort a shutdown that's currently underway (perhaps one that you've set on a timer). For a full rundown of all the ways you can use this command, including some advanced options for IT managers (such as remote shutdowns), check out the official Microsoft documentation.