SHUTDOWN - CMD
Overview
The SHUTDOWN
command in Windows CMD is used to shut down, restart, or log off the local or a remote machine. It is primarily used by administrators to manage power functions on multiple computers in a network environment or for script automation of system maintenance.
Syntax
The basic syntax of the SHUTDOWN
command is:
shutdown [/i | /l | /s | /r | /g | /a | /p | /h | /e] [/f] [/m \\computername] [/t xxx] [/d [p|u:]xx:yy] [/c "comment"] [/o]
Where each parameter can be defined as:
/i
: Display GUI interface, must be the first option/l
: Log off, cannot be used with/m
or/d
options/s
: Shut down the computer/r
: Restart the computer/g
: Restart the computer and restart any registered applications/a
: Abort a system shutdown, only valid during the timeout period/p
: Turn off the local computer with no timeout or warning, can be used with/d
and/f
options/h
: Hibernate the local computer, can be used with the/f
option/e
: Document the reason for an unexpected shutdown/f
: Force running applications to close without warning/m
: Specify the target computer/t xxx
: Set a timeout for shutdown, in seconds/d [p|u:]xx:yy
: Provide the reason for restart or shutdown/c "comment"
: Comment on the reason for restart or shutdown/o
: Go to the advanced boot options menu and restart the computer
Options/Flags
- /i: Use if you need to shut down/restart/log off multiple remote computers simultaneously using a Graphical User Interface (GUI).
- /l, /s, /r, /g: Choose based on whether you are logging off, shutting down, restarting, or rebooting (and restarting apps), respectively.
- /f: Typically used in scripts or when applications hang and do not close by themselves during shutdown or restart.
- /t xxx: Useful for giving users or processes a grace period before shutdown/restart.
- /d, /c: Important for system administrators to log specific reasons or comments for shutdowns or restarts, aiding in troubleshooting and system management.
Examples
- Simple Shutdown:
shutdown /s
- Restart the Computer with a Custom Message and 30-second Delay:
shutdown /r /t 30 /c "Restarting for maintenance"
- Abort a Previously Scheduled Shutdown:
shutdown /a
- Shut Down a Remote Computer:
shutdown /s /m \\workstation01 /f
Common Issues
- Access Denied Error: Make sure you have administrative privileges to shut down or restart the target computer.
- Shutdown Aborts: Check for an
/a
command running in a script or another user aborting the scheduled shutdown. - Network Issues: Ensure the target machine name in
/m
is correct and accessible over the network.
Integration
Combine SHUTDOWN
with other CMD commands for powerful scripting. For example:
-
Scheduled System Reboot at Midnight:
at 24:00 shutdown /r
-
Batch File for Weekly Reboot:
echo off :loop shutdown /r /t 300 timeout /t 604800 /nobreak goto loop
Related Commands
- CMD: Use for other command line operations.
- TASKSCHD.MSC: Schedule automated tasks including shutdown or restart.
- PSSHUTDOWN: Part of Sysinternals Suite, for advanced shutdown operations.
For more detailed information, visit the official Microsoft documentation for the SHUTDOWN
command: Windows Shutdown Command Documentation.