Programming Field

Shutdown - DOS/Command Prompt Reference

[Windows XP or later] Performs a system shutdown (restart or power off).

Syntax

shutdown[.exe] [/i | /l | /s | /sg | /r [/o] | /g | /a | /p | /h | /e]
    [/f] [/m \\<computer>] [/t xx]
    [/c "comment"] [/d [[u|p]:]xx:yy]
    [/hybrid] [/soft] [/fw]

(* The case (upper or lower) is not distinguished.)

* Only one of /i, /l, /s, /sg, /r, /g, /a, /p, /h, /e, or /o can be specified.

[Windows XP] In the help, options are displayed starting with ‘-’ but can be specified starting with ‘/’.

Options

/i

Displays a dialog (GUI) to select the type and reason for shutdown and shutdown a remote computer.

This option must be specified first. If this option is specified, other options will be ignored.

/l (/L) Logs out (logs off). If this option is specified, /m, /c, /d, and /t cannot be specified.
/s Shuts down the computer.
/sg [Windows 10 or later] Shuts down the computer. If Automatic Restart Sign-On (ARSO) is enabled, it automatically signs in the user from before the shutdown at the next startup and locks the session. It also automatically launches registered applications (see Details).
/r Restarts the computer.
/o [Windows 10 or later] When used with the /r option, it moves to the Advanced Boot Options screen.
/g

[Windows Vista or later] Restarts the computer. After the restart, it automatically launches registered applications (see Details).

[Windows 10 or later] If Automatic Restart Sign-On (ARSO) is enabled, it automatically signs in the user from before the restart and locks the session after the restart.

/a Cancels the shutdown process that is waiting for a timeout. This is used when Shutdown is executed with the /t option specifying a number greater than 0, causing a timeout wait for shutdown (restart). Use this to stop the timeout wait.
/p [Windows Vista or later] Performs a shutdown (power off) of the local computer without a timeout. If this option is specified, /m, /c, and /t cannot be specified, but it can be used in conjunction with /d and /f.
/h [Windows Vista or later] Puts the local computer into hibernate mode. If this option is specified, /m, /c, /d, and /t cannot be specified.
/e

[Windows Vista or later] Registers a record in the Event Log stating ‘An unexpected shutdown occurred’. Used in conjunction with the /d and /c options.

Note that administrative privileges are required to execute this option.

/f

Forces a shutdown (or restart) regardless of whether running applications are canceled or not.

If the /t option is used to specify a number greater than 0 for shutdown, /f is implicitly used.

/m \\<computer>

Performs a shutdown (restart) of a remote computer. <computer> will be the computer name. (The ‘\\’ is optional.)

Special permissions are required for remote computer shutdown (administrative privileges can be used). Additionally, the user connecting to the remote computer must have the ability to shut down on that remote computer (you can connect in advance using the ‘net use’ command).

/t xx

Specifies the timeout period until shutdown. xx will be a value in seconds within the range of 0 to 315360000 (10 years).

If this option is not specified, the timeout period defaults to 30 seconds. Additionally, if the timeout period is not 0, the /f option is implicitly used.

/c "comment" Adds a comment (shutdown reason) to the Event Log for shutdown. If there is a timeout period, it is also used for the message displayed indicating the intention to shut down. comment will be its comment, and the presence or absence of double quotation marks (‘" "’) does not matter.
/d [[u|p]:]xx:yy

Specifies the shutdown reason code to be recorded in the Event Log. The specified values are as follows:

u: Indicates a user-defined reason code by specifying a colon followed by the ‘u’ character.
p: Indicates that this shutdown is a planned shutdown by specifying a colon followed by the ‘p’ character. If ‘p’ is not specified, it indicates an unplanned (unexpected) shutdown, and depending on the policy, an error report stating ‘An unexpected shutdown occurred’ may be displayed at the next startup.
xx Specifies the major code (main reason) of the reason code in the range of 0 to 255. This value is used as a multiplier by 65536 when generating the reason code.
yy

Specifies the minor code (sub-reason) of the reason code in the range of 0 to 65535.

For details on reason codes, please refer to ‘System Shutdown Reason Codes’. (Specify the value obtained by dividing the major code in the listed codes by 65536 (0x10000).)

/hybrid

[Windows 10 or later] Used in conjunction with /s to enable fast startup and shut down the computer.

* By default, without using this option, fast startup is disabled. This differs from the default behavior when shutting down from the Start menu, where fast startup is enabled.

/soft

[Windows 10 or later] Performs a ‘soft restart’. (Details unclear; corresponds to the SHUTDOWN_SOFT_REBOOT option in InitiateShutdownW.)

This option must be used in conjunction with the /r or /g option.

/fw

[Windows 10 or later] Used in conjunction with shutdown options (/s, /sg, /r, /g, /p) to display the firmware's user interface (BIOS menu, etc.) at the next boot.

Administrative privileges are required to use this option.

Details

Shutdown types and options

Usage of Shutdown

Using Shutdown allows you to perform computer shutdown or restart from the command line. The options to be used depend on the type of shutdown, as follows:

TypeOption
Logoff/l
Shutdown (Power off)/s, /sg, or /p
Reboot/r or /g
Hibernate/h

If you use the /t option to specify a timeout period of more than 1 second, a message indicating the intention to shut down will be displayed on the target computer, and the shutdown will take place after the specified timeout period. In this case, the Shutdown program itself completes its execution before the timeout period elapses, so returning from the Shutdown command does not necessarily mean that the computer has shut down at that moment. (There is also the possibility that the shutdown has been canceled with ‘shutdown /a’.)

Restarting registered applications

With the /g option or /sg option, there is a behavior to ‘restart registered applications’ at the next startup. ‘Registered applications’ are typically applications that perform specific tasks, such as restoring sessions after a restart, and are registered through certain processes while running. Please note that not all applications will be restarted; only those that support this feature will be restarted.

* To register an application as a "registered application," you can use the RegisterApplicationRestart function. (This function is used to enable an application to be restarted in case of an error.)

[Windows 10 or later] When using /s and /sg, if the ‘Automatic Restart Sign On (ARSO)’ feature for the logged-in user is enabled, the user will be automatically logged in at the next startup (logging in and "locking" the session, so the login screen will still be displayed as if not logged in). ARSO is controlled by the following settings:

  • Windows 10 prior to 1903: Settings → Accounts → Sign-in options → Privacy → ‘Use my sign in info to automatically finish setting up my device after an update’
  • Windows 10 1903 or later: Settings → Accounts → Sign-in options → Privacy → ‘Use my sign-in info to automatically finish setting up my device and reopen my apps after an update or restart’
  • Windows 11 : Settings → Accounts → Sign-in options → Advanced → ‘Use my sign-in info to automatically finish setting up after an update’

Samples

Sample 1

shutdown /s /t 0

Immediately shuts down the local computer. However, if there are unsaved data or other conditions requiring confirmation, a dialog may prompt for confirmation, allowing the option to cancel the shutdown from there.

Sample 2

shutdown /g /t 60 /d p:4:1

[Windows Vista or later] Restarts the computer and, at the next startup, restarts supported applications. Also, records the reason for the restart as ‘Planned application maintenance’.