How to use the Windows shutdown command

0
243

Most Windows users shut down the PC either through the start menu, Alt-F4 menu, or by pressing the power button on the device.

The shutdown command provides you with options to change a Windows computer’s power state. It enables you to shut down, restart, hibernate the computer, log off a user, and customize the shut down experience. The command supports local and remote shutdowns on top of that, and you may use it to stop a shutdown or restart that is in process.

How to use the Windows shutdown command is the first part of a series that looks at important Windows command line programs.

The Windows shutdown command

windows shutdown command

You run shutdown from the command prompt or PowerShell interface. What you can do however is create shortcuts so that you don’t have to write the commands each time you want to use them, but can simply click on the shortcut instead to run them. This is explained later in the guide.

First thing you need to do is open a command prompt window:

Tap on the Windows-key, type cmd.exe, and hit the Enter-key on the keyboard.

The following major commands are provided

  • shutdown /a — This command stops a shut down or reboot process. Can be useful if Windows Update decided that it is time to reboot the PC, or if your actions or other programs started the process.
  • shutdown /s — The shutdown command. This shuts down the computer when you run it.
  • shutdown /r — Shuts down the computer, and restarts it afterwards.
  • shutdown /g — Like shutdown /r, but will restart any registered program when the system has loaded.
  • shutdown /h — Hibernates the local computer.
  • shutdown /l — Logs off the current user.
  • shutdown /p — Turns the computer off without prior warnings. Equals running shutdown /s /f /t 0

The following additional commands are supported

shutdown i graphical user interface

The shutdown /i GUI

  • /e — This enables documentation for the shutdown of the computer.
  • /i — Show the graphics user interface. Must be the first option of the command, and all other switches are ignored (as the graphical user interface is loaded).
  • /hybrid — Shuts the computer down, and enables Fast Startup. Must be used with /s
  • /t 0 — Sets the timeout period before the shutdown. The default is 30 seconds, and you may speed things up by setting /t 0.
  • /f — Forces running programs to terminate without user warning.  Also /force.
  • /m \computer — Specify a remote computer that you want to run the command on.
  • /c “remark” — Adds a comment that explains the reason for the shutdown or restart of the computer. Supports a maximum of 512 characters, and is displayed on the shutdown prompt.
  • /d — Adds a reason for the restart using a system of codes. Basically, /d p:1:2 indicates a planned shutdown because of a hardware installation, while /d u:1:2 a user defined shutdown because of a hardware installation. You can leave out p and u to set an unplanned reason for the shutdown. The table with major and minor reasons is displayed when you run shutdown /?.
  • /o — This command restarts the PC and loads the Advanced Boot Menu on the next start. Needs to be run with /r

Shutdown Command Examples

The following examples highlight some command shutdown command switches.

Run a fast shutdown. This forces applications to close, and sets the

  • shutdown /s /f /t:0

Restart the computer, and add a reason for the restart. Computer will restart in 30 seconds, as t command is not specified

  • shutdown /r /d u:2:1

This command shuts down the remote computer ComputerXYZ after 300 seconds forcefully, adds a reason for the shutdown, and displays the comment in the shutdown prompt.

  • shutdown /m \ComputerXYZ /s /f /d p:1:2 /c “Computer will restart for maintenance, save your work” /t 300

Creating shutdown shortcuts

While you can run shutdown from the command prompt whenever the need arises, you may also create shortcuts or batch files so that you can run them with a double-click directly without having to open the command prompt or remembering the commands.

Option 1: Batch Files

shutdown bat

The first option that you have is to create a batch file.

  1. Right-click on the desktop or another location in Explorer, and select New > Text Document.
  2. Write or paste the shutdown command or commands that you want to execute using it, e.g. shutdown /s /f /t:0
  3. Save the document.
  4. Rename it to fastshutdown.bat (choose a different name depending on the purpose). Make sure the extension is .bat, and not .bat.txt.

Double-click on the file to test it. Make sure you save all your work before you do so to avoid any issues in this regard.

You can add multiple shutdown commands, for instance for several remote machines. Make sure each new command starts on a new line.

Option 1: Shortcuts

shutdown shortcut

Shortcuts work pretty much like batch files, but they are limited to a single command.

  1. Right-click on the desktop or another location in Explorer, and select New > Shortcut.
  2. Type or paste the command in the field on the “what item would you like to create a shortcut for” page. Click next.
  3. Name the shortcut afterwards, and click finish.

Shutdown Programs for Windows

You may run programs designed specifically to shut down Windows PCs. Most are quite old, but work just fine. Please note that some antivirus solutions may flag those because of what they do.

  1. Superfast Shutdown — Long standing program, shuts down the Windows PC in record time.
  2. Shutdown Scheduler — Lets you schedule the shutdown of a Windows computer
  3. Absolute Shutdown — Designed to make shutting down Windows XP faster. May work on other versions of Windows as well.
  4. WinOFF — Program designed for scheduling the shutdown of Windows computers.

Additional resources

  • Analyze the boot and shutdown performance of Windows
  • Microsoft Technet shutdown