What is the Shutdown Command?
The shutdown command is a command you type into your dos CMD (command) window to shut down, restart, log off, or hibernate your computer. You can also use this command remotely if you have access to other computers over a network. For example you can shut down a computer when using remote desktop to access it.
There is one main command, shutdown, and many switches that can be added to change the command. For example if you want to shutdown your own computer you would type: shutdown /s. But if you wanted to restart the computer then you would type: shutdown /r.
Shutdown Command Line Switches
Here is a detailed list of the switches you can use. To see these details simply open a cmd window and type in shutdown /?. In the screenshot below you can see the results you will get.
shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e |/o] [/hybrid] [/f] [/m \\computername] [/t xxx] [/d[p:|u:]xx:yy] [/c “comment“] [/?]
/i = This shutdown option shows the Remote Shutdown Dialog, a graphical version of the remote shut down and restart features available in the shutdown command. The /i switch must be the first switch shown and all other options will be ignored.
/l = This option will immediately log off the current user on the current machine. You can not use the /loption with the /m option to log off a remote computer. The /d, /t, and /c options are also not available with /l.
/s = Use this option with the shutdown command to shut down the local or /m defined remote computer.
/r = This option will shut down and then restart the local computer or the remote computer specified in /m.
/g = This shutdown option functions the same as the /r option but will also restart any registered applications after the reboot.
/a = Use this option to stop a pending shut down or restart. Remember to use the /m option if you’re planning on stopping a pending shut down or restart that you executed for a remote computer.
/p = This shutdown command option turns off the local computer completely. Using the /poption is similar to executing shutdown /s /f /t 0. You can not use this option with /t.
/h = Executing the shutdown command with this option immediately puts the computer you’re on into hibernation. You can not use the /h option with the /m option to put a remote computer into hibernation, nor can you use this option with /t, /d, or /c.
/e = This option enables documentation for an unexpected shut down in the Shutdown Event Tracker.
/o = Use this shutdown switch to end the current Windows session and open the Advanced Boot Options menu. This option must be used with/r. The /o switch is new beginning in Windows 8.
/hybrid = This option performs a shutdown and prepares the computer for fast startup. The /hybridswitch is new beginning in Windows 8.
/f = This option forces running programs to close without warning. Except with the /l, /p, and /hoptions, not using shutdown’s /f option will present a warning about the pending shut down or restart.
/m \\computername = This shutdown command option specifies the remote computer that you want to execute a shut down or restart on.
/t xxx = This is the time, in seconds, between the execution of the shutdown command and the actual shut down or restart. The time can be anywhere from 0 (immediately) to 315360000 (10 years). If you don’t use the /t option then 30 seconds is assumed. The /toption is not available with either the /l, /h, or /p options.
/d [p:|u:]xx:yy = This records a reason for the restart or shut down. The p option indicates a planned restart or shut down and the u a user defined one. The xx and yy options specify major and minor reasons for the shut down or restart, respectively, a list of which you can view by executing the shutdown command without options. If neither p nor u are defined, the shut down or restart will be recorded as unplanned.
/c “comment“ = This shutdown command option allows you to leave a comment describing the reason for the shut down or restart. You must include quotes around the comment. The maximum length of the comment is 512 characters.
/? = Use the help switch with the shutdown command to show detailed help about the command’s several options. Executing shutdown without any options also displays the help for the command. For example shutdown /? and then press enter.
Tip: Each time Windows is shut down or restarted manually, including via the shutdown command, the reason, type of shut down, and [when specified] comment are recorded in the System log in Event Viewer. Filter by the USER32 source to find the entries.
Shutdown Command Line Examples
shutdown /r /d p:0:0
In the above example, the shutdown command is used to restart the computer that’s currently being used and records a reason of Other (Planned). The restart is designed by /rand the reason is specified with the /d option with p representing that the restart is planned and the 0:0 indicating an “Other” reason.
Remember, major and minor reason codes on a computer can be displayed by executing shutdown without options and referencing the Reasons on this computer table that’s displayed.
Using the shutdown command as shown here, the current computer is immediately logged off. No warning message is displayed.
shutdown /s /m \\SERVER /d p:0:0 /c "Restart by Mitz"
In this shutdown command example, a remote computer named SERVER is being shut down with a recorded reason of Other (Planned). A comment is also recorded as Restart by Mitz. Since no time is designated with the /t option, the shutdown will begin on SERVER 30 seconds after executing the shutdown command.
shutdown /s /t 0
Finally, in this last example, the shutdown command is used to shut down the local computer immediately since we designated a time of zero with the shutdown /t option.
If you want to stop the shutdown then you can quickly use /a command switch. But just remember that if you have set the time to zero for shutting down then you might not be able to stop it as the process will be too quick. To use this /a switch it has to be typed into a run box. If you are quick enough to press Windows Key and R to open run, then type in shutdown /a then you will stop the process.
Create a Shutdown Desktop Icon
You can create a shutdown desktop icon using one of the above codes. Then when you press on your icon the command will be executed. For example if you have used the shutdown /s /t /0 command then when you press the icon the computer will shut down in zero seconds.
Watch this video to see how. Please note that this video is old and may not work for Windows 8, however it does apply to Windows XP to Windows Seven.