How to shutdown, restart, logoff using command prompt?

Windows provides a builtin command to shutdown, restart as well as logoff a user from the command promptne. This and many other options are provided by the “shutdown” command. In order to find out more options of any command, type :

shutdown /? – command name followed by a forward slash and a question mark.

in Command Prompt ( WIN + R ยป cmd – here are some more Windows Keyboard shortcuts. You can run any command from Command Prompt or typing the command with full option into the RUN Dialog ( WIN + R ) The main use of all these commands come in batch files and task scheduling. All of these commands are pretty easy to use, please read the article completely before complaining ;)

Basic form of “shutdown”

The most basic form of the command is :

shutdown -OPTION
shutdown /OPTION

Both perform the same thing – execute shutdown command with option OPTION. OPTION can take many values, only the ones of interest to us are mentioned here.

-l – Logs off the current user
-s – Shutdown the computer
-r – Restart the computer

-a – Aborts a current shutdown command execution

-t XX – if this is added with any of the above ones, you can specify after what time ( XX seconds ) the system should execute the OPTION.

A Simple example and a Screenshot

Here the OPTIONs specify that shutdown command should shutdown the command after 120 seconds.

RUNning “shutdown” command with options -s -t 120

shutdown -s -t 120

The screen result will be something like this :

Before shutdown, the logged in user is warned about the event and the time frame.

Canceling a shutdown

If you have given the time parameter -t XX you will have sometime before the command kicks you out. In that time, if you want to cancel the event just type :

shutdown -a -Abort a shutdown

shutdown Aborted – notification

Add a message

You can add a custom message with shutdown so that, instead of the time frame warning, the user will be presented with your message.

shutdown -s -t 120 -c “You are so screwed”

will present the user with the message – “You are so screwed” as below :

Custom message with “shutdown”

More about shutdown on Microsoft KB | Built in parental control in Windows XP