How To Shutdown Windows From Command Line with Shutdown Command Examples and Tutorial
Windows operating systems provides the
shutdown command which have a lot of functions like reboot, shutdown, logoff etc. In this tutorial we will look most useful of them. Windows XP is very old operating system where it may lacks some of options and features described here. We will use
cmd.exe to run from cli.
shutdown command syntax is like below.
shutdown OPTIONS COMPUTER COMMENT
OPTIONSis used for different type of options like restart, logoff etc.
COMPUTERis used when we need to run
shutdowncommand on remote computer
COMMENTis used with comment feature to provide message
Now the main purpose of
shutdown command is shutting down the system or computer. Just providing the
shutdown command is not enough. We should provide the
/s option in order to shutdown the system.
> shutdown /s
We can also restart system with the
shutdown command. We will provide the
/r option in order to restart the system or computer. This will shutdown and restart the computer.
> shutdown /r
Logout From Current GUI Session
If we have logged in with the GUI we may need to logout from current session. We will use
/l option in order to logout from current user session.
> shutdown /l
Abort System Shutdown
By default when we issue shutdown command the computer will not shut down immediately. There is 60 seconds wait time before shutdown. We can cancel the shutdown operation with
/a which means abort.
> shutdown /a
Hibernate feature will make computer sleep and wake up in seconds without starting from scratch. We can hibernate the computer with the
/h option like below.
> shutdown /a
Send Message To System Users
A typical server will be used more than one person. There may be other persons who is using server currently. We need to provide information about shutdown, restart. We can use
/c option with the message. Message will be put into double quotes.
shutdown /s /c “The system will be shutdown in 60 seconds.”
Specify Time or Interval For Shutdown and Restart
Default shutdown interval or time may be enough for us or other computer and system users. We can specify the interval we need with the
/t option and time value. In this example we will specify waiting time for 120 seconds for shutdown. Merging this option with send message will be very useful.
> shutdown /s /t 120 /c "Shutdown in 120 seconds"