If All Else Fails, Use Command Prompt to Shut Down Windows

In an ideal world, you would live a long and happy life just by shutting down and restarting your computer through the Start menu. Click the power icon, select an option, and you’re done. However, life doesn’t always work out the way we plan, and sometimes you may need to run a reboot or shutdown from the command line instead.
There may be something preventing the Start menu from working, or perhaps you’ve found yourself on a screen where the Start menu is inaccessible. One of the scenarios in which I use the Command Prompt to shut down Windows is when I’m in the initial stages of installing the operating system and don’t want to shut it down right away.
You may also have downloaded the Command Line Interface to try to fix an issue that’s preventing Windows from working—in which case, you’ll need to know how to shut down or restart your computer without pressing and holding the power button. (If you’re having problems with your computer, see also the lesser-known emergency restart option .)
Using the Command Line
If you’re new to the Command Prompt, it’s a text-based interface hidden in Windows, a relic of the old days when computer operating systems didn’t have pointers and graphical user interfaces, and which is still useful for performing various low-level system operations.
The command line is also accompanied by PowerShell, a more modern and feature-rich version of this interface. As for the shutdown and restart commands, you can use any of them for this job, but if you ever need to run more complex text commands, scripts, and automations, it’s best to configure PowerShell to run them.
You can launch Command Prompt or PowerShell from the Start menu. Just type the first few letters of any utility into the search box at the top to find them. There are also various other options, such as right-clicking the Start menu button and selecting Terminal , or typing “cmd” into the taskbar search box and pressing Enter .
Using the shutdown command
The text command needed to shut down or restart a Windows computer is “shutdown.” If you type it into the Command Prompt or PowerShell and then press Enter , you’ll get a full description of the shutdown and all the ways it can be used (by the way, you can add “|more” to this or any command to see a page of text at the same time).
Type “shutdown /s” to trigger a standard shutdown.
The most basic flags you’ll need are “shutdown /s” and “shutdown /r” to shutdown and restart your computer, respectively. In both cases, you will see a dialog box on the screen telling you what is happening, and the action will be completed in less than a minute. These commands initiate the normal shutdown process, so you will be prompted to save any unsaved work in open programs that normally do so.
Type “shutdown /s /f” to force shutdown.
To force close all applications without any additional prompts (perhaps if you need to make sure the shutdown or restart goes smoothly), add “/f” to the end of your command (that is, either “shutdown /s /f” to shutdown or “shutdown /r /f” to restart). However, you do this at your own risk, risking losing data that has not yet been saved, and it’s probably best left as a last resort.
Type “shutdown /r /o” to access additional boot options.
The “shutdown /r /o” command is useful for troubleshooting because it restarts the computer and opens the Advanced Boot Options screen. It’s what gives you access to features like using a USB drive to restore your computer, running the built-in startup repair utility, and rolling back the latest Windows updates. From here you can also return to the command line without starting the operating system.
Set the shutdown time by adding “/t”
Another flag that can be useful is the “/t” flag followed by a space and a number. This causes a delay in shutdown or restart, giving you time to close apps or finish booting. The number is the number of seconds Windows has to wait, and it can range from 0 (instant) to 315360000 – that’s 10 years, in case you were wondering. If seconds are set to a value greater than zero, the “/f” flag is also applied.
Stop shutdown using “shutdown /a”
One last thing you might find useful: you can use “shutdown /a” to interrupt the current shutdown (perhaps one you’ve set on a timer). A full description of all the ways to use this command, including some additional options for IT managers (such as remote shutdown), can be found in the official Microsoft documentation .