How to shutdown, restart, logoff using command prompt?

One windows command can be used to shutdown, restart as well as logoff a user in Windows. This and many other options are provided by the “shutdown” command. In order to find out more options of any command, type :

COMMAND /? – 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
OR
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

Some related articles you may like :

  1. Running a command, applying changes and other Windows Techniques
  2. Hide files under other files (merge) using command prompt
  3. Built in parental control in Windows XP – control user login times
  4. Batch files to automate tasks in Windows environment – tutorial
  5. Free parental control software for Windows, MAC and iPhone
  6. Correction to the list files and folders from a directory to a file
  7. What are the hidden files and folders
  8. First step to a cleaner and faster Windows – understand the Registry

This entry was posted in Uncategorized and tagged Admin, Command Prompt/Shell, Tips. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

14 Comments

  1. Posted January 24, 2012 at 6:04 PM | Permalink

    Hi All,

    To shutdown a computer via a network or lan.. click stat / run / shutdown -i

    Enter the compuer name. Select the option from the drop down menu “shutdown” “Restart” or “Logoff” set the time to show the message. then have the message to what ever you like then press ok.

  2. Rustam Kumar Singh
    Posted November 23, 2011 at 5:36 PM | Permalink

    Dear Leam it work in windows 7 please follow the instruction it helps in all the command
    shutdown -r
    shutdown -s
    shutdown -l

  3. Posted October 20, 2011 at 12:35 AM | Permalink

    i did the shutdown trick and tried to abort it but it didnt work. maybe its because i windows 7.

  4. Posted September 21, 2011 at 7:34 AM | Permalink

    You are right, PS tools does have that. I haven’t tried this on another Win machine, but the doc says that.

  5. The App
    Posted September 6, 2011 at 11:10 PM | Permalink

    I don’t think you can run this command on a remote computer. I think pstools can help you acheive this. PSTools lets you run commands on remote computers.

  6. Posted July 24, 2011 at 2:34 PM | Permalink

    Great Job! I have a bone deformity in my mouse hand and due to the pain that come after an extended period of time with a mouse, this makes my life just a little easier. Thanks so much!

  7. Eddie
    Posted March 15, 2011 at 3:04 PM | Permalink

    please send me an instruction on how to shutdown other user’s desktop using command sign.

  8. Posted January 13, 2011 at 11:29 PM | Permalink

    Hi Karry,
    that’s true. Even I was thinking about changing it. Will change it soon :) .

  9. Posted January 13, 2011 at 7:41 PM | Permalink

    Hi man, I like your blog but you should really change the blog template, this one is not very good.

  10. Albert
    Posted July 17, 2010 at 5:49 AM | Permalink

    I’m trying to test this batch file but not working, can somebody how I can change it to work:

    %rightnow% = time /t
    %starttime% = “12:00 AM”
    %endtime% = “05:00 AM”

    rem “trying to find out if current time is between 12 and 5 AM”

    if “%rightnow” geq “%startime” and %rightnow% leq %endtime%

    echo “between 12 and 5 AM”
    else
    echo “it is okey”
    end

    quit

  11. Posted April 2, 2009 at 1:13 PM | Permalink

    Hi Phalla,
    can you please tell me the specific error shown when you type the command.. or better can you add a screen shot of the command prompt when you do this.

  12. Phalla
    Posted April 2, 2009 at 11:20 AM | Permalink

    i know all this command but i cannot restart a pc in network. why? All you detail about this command are useful but i still cannot do it.

  13. Posted March 7, 2009 at 1:33 AM | Permalink

    Hi Arne please try the IP of the computer you are trying to shutdown. Use IP.IP.IP.IP instead of \\XXXXX The IP of the remote computer can be found easily by opening the command prompt and then typing “ping \\XXXXX” You can see the IP there. Please tell me if your problem have been resolved.

  14. Arne
    Posted March 7, 2009 at 1:29 AM | Permalink

    Hello! When i am using any commands on my computer it works great, but if i’m trying to use it on a computer in a LAN it doesn’t word, it just syas that it can’t find the network adress.
    I’m typing in the following command:
    shutdown /s /m \\XXXXX /t 005

    and i’ve checked that the computer name is correct.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>