Google for Linux Users? The Institute for Advanced Personhood

Windows Tip: Shutdown Your Computer With The Command Prompt

Written by Saman Sadeghi on January 14, 2007 Add comments

This is one of my favorite tricks, shutting down my Windows XP machine with one simple line of code!

This might not seem necessary since the power button is tucked neatly inside the Start Menu, but this trick has a few more uses. Not only can you use this on your machine, but on network machines as well - as long as you have administrative access! You can also restart machines, set comments (the reason for the shutdown), specify time and more!

List Of Shutdown Command Switches

No Switches Display information about the shutdown command, same as typing “-?”
-i Display a GUI. It must be the first switch
-l Log off the user (This cannot be used on a remote machine: “-m” switch)
-s Shutdown the computer
-r Restart the computer
-a Cancels a system shutdown already in progress
-f Forces running applications to close without warning
-m \\computername Instruct a remote computer to shutdown (can be used with the restart & abort switches)
-t xx Set a given time for shutdown, in seconds
-c “comment” Shutdown comment (maximum of 127 characters)
-d [u] [p]:xx:yy The reason code for the shutdown:
u is the user code
p is a planned shutdown code
xx is the major reason code (positive integer less than 256)
yy is the minor reason code (positive integer less than 65536)

How To Use Shutdown Switches:


You don’t have to use them all, but the switches you do use must be in the following order:

shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]

How To:

Open the command prompt: Windows Key + R then type the command below and hit OK:

cmd

This will open the command prompt. Now we can play!

Note: You could type the shutdown command directly into the Run dialog. I don’t advise this. If there is a typo or error, you won’t know. There is no information given!

Shutdown Local Machine

This only takes a couple of keystrokes. Type the code below and hit OK:

shutdown -s

“shutdown” tells the computer what command we want to execute and the “-s” switch tells it what to do, which is to shutdown!

Specify Time

shutdown -s -t 60

Now we have added the “-t” switch and a variable, which in this case is “60″. This number is the number of seconds before the computer is shutdown. A dialog will open and display a count down timer!

Give Us Some Info!

shutdown -s -t 120 -c "You better finish, because I shut you down foo!"

The “-c” switch will allow you to give the user some information for the reason of the shutdown.

Shutdown A Remote Computer

shutdown -s -m \\desktop -t 45

I really like this one! The “-m” switch will allow you to shutdown a remote machine, in this case, a computer named “desktop”. For this to work, you must have administrative access to the computer! To see of you do, hit Windows Key + R then type the computer’s name, i.e.:

\\desktop

If you can connect to it, you will be asked to log into the machine with a user name and password. Once confirmed, a window will open displaying the directories available to you. Now you know you can shut it down remotely.

Cancel Shutdown

Let’s say that you need to cancel a shutdown in progress. Go to the computer in question, hit Windows Key + R then type command below:

shutdown -a

This will abort the shutdown, assuming there is a counter and it hasn’t reached zero yet!

This post is filed in: Command Prompt, Windows Tips And Tricks and has been viewed 19,940 views times.

Google for Linux Users? The Institute for Advanced Personhood

Kuribo Mario Hops For These Related Posts:


Kuribo Mario
  • Windows Tip: Log Off Your Computer With A Shortcut
  • Windows Tip: Shutdown Your Computer With A Batch File
  • Shutdown Multiple Windows Machines From The Command Prompt
  • Windows Tip: Start Your Day With A Fresh Computer, Step Four: Automate A Reboot
  • Customize The Command Prompt


  • RSS feed | Trackback URI

    58 Comments »

    Pingback by Speed Linking, March 7, 2007 | Samanathon.com 2007-03-07 09:15:31

    MyAvatars 0.2

    [...] or reboot it with ” -r” If you want to learn more, here’s my article on the Command Prompt Switches. He also has a version for putting you Mac to sleep via email - which you could do both via [...]

     
    Comment by C More 2007-03-13 13:29:23

    MyAvatars 0.2

    Ah! Abandon Ship!! That could come in handy.

    Comment by Saman 2007-03-13 14:53:09

    MyAvatars 0.2

    I use it all of the time - especially if I’m feeling too lazy to walk across the room to shut down a machine!

     
     
    Comment by Jon Lee 2007-03-15 19:22:01

    MyAvatars 0.2

    I use this to create a great big SHUTDOWN icon on the computer at my parent’s house - so they would stop pulling the plug out of the wall to shut down the computer.

    Comment by Saman 2007-03-15 20:07:52

    MyAvatars 0.2

    Oh man, that is hilarious! I remember when we used to unplug our 386 too! :lol:

     
    Comment by Natron 2007-03-28 13:54:52

    MyAvatars 0.2

    That is just to much! I suppose if it’s right on the screen they may actually use it once in a while…

     
     
    Comment by 2Perfect 2007-04-18 20:00:09

    MyAvatars 0.2

    ooh i’ve read about this before…

    but whenever I try to shutdown a remote computer, it doesn’t do anything. It works when I’m shutting down my laptop though.

    I typed in //mainframe (that’s the name of the computer) and it didn’t ask for a username/password but instead just opened the directories. How would I set my laptop to become an administrator for that computer?

    Also is there anyway to turn a computer on remotely? I use my family’s desktop for storage and my parents always turn it off after they use it and I’m too lazy to turn it on to get files on the network drive :P

    Thanks in advance!

    Comment by 2Perfect 2007-04-22 20:07:39

    MyAvatars 0.2

    sorry for the double comment but I’m not sure if you’ve seen this…

    1) How do i set my laptop as an administrator for the desktop? (check comment above)
    2) Is there a way to turn a computer on remotely?

    Comment by Saman Sadeghi 2007-04-22 20:45:12

    MyAvatars 0.2

    I’m not 100% sure….

    Try making sure they’re both on the same workgroup and make accounts on both machines that have passwords…

    I know that you can access files on the other machine using:

    //mainframe/c$

    Comment by Saman Sadeghi 2008-04-16 12:50:04

    MyAvatars 0.2

    I just realized that I missed you second question, I’m not too familiar with Wake on Lan but it looks like you need some prerequisites:

    Getting Wake On Lan (sometimes called Remote Wake Up) to work

     
     
     
     
    Comment by me 2007-04-23 22:06:40

    MyAvatars 0.2

    i use this and speard it arround the internet so people think they got big virus

     
    Comment by wade 2007-05-16 22:24:39

    MyAvatars 0.2

    email me at [email removed] because i need some hints on how to shut down computers on a lan server (such as at School)

     
    MyAvatars 0.2

    [...] a new batch file and write a shutdown command. All you really need [...]

     
    Comment by 2Perfect 2007-07-24 17:28:44

    MyAvatars 0.2

    So how do you run a shutdown from a file? Can’t figure out how :P

    Comment by Saman Sadeghi 2007-07-24 21:01:04

    MyAvatars 0.2

    Check this post out: Windows Tip: Shutdown Your Computer With A Batch File

    Let me know if you need more help!

     
     
    Comment by chris 2007-08-26 08:35:21

    MyAvatars 0.2

    hey i had made a batch file with the command shutdown but i want to schedule that batchfile in a timer everyday without my approval it should shutdown or restart from a particular time say from 1:00pm to 4:00pm it should only restart the computer………………….
    Do anyone know that how to scheduled the timer……………….

    Comment by Saman Sadeghi 2007-08-26 14:52:49

    MyAvatars 0.2

    Chris, I wrote about scheduling a shutdown with a batch file. Let me know if you need any help!

     
     
    Comment by Drakord 2007-08-28 02:44:51

    MyAvatars 0.2

    :?: I have two computors in my house and i want to shut down computor 2 (XP) using computor 1(Vista) I have got up to the very last part but when i press enter it comes up with \\computor 2: Access is denied

    can someone tell me how to fix this problem
    if the answer is administrative access can you tell me hoe to do that

    Thank you very much,

    Drakord :razz:

     
    Comment by matt 2007-09-02 02:59:21

    MyAvatars 0.2

    is there any way of making a logoff version into a desktop shortcut?

    Comment by Saman Sadeghi 2007-09-03 21:40:48

     
     
    Comment by juan 2007-09-04 07:13:52

    MyAvatars 0.2

    I need HELP!!!!!!!!!! I used the shutdown command followed by my roomates IP address. Apparently two computers shutdown and they are having a hard time connecting to the internet.

    Comment by Saman Sadeghi 2007-09-07 22:29:08

    MyAvatars 0.2

    That odd - for one, they shouldn’t have the same IP address. Two, the shutdown command only shutsdown the computer - just as if you clicked Start->Shutdown.

    Check for viruses or maleware….

     
     
    Comment by hunter 2007-09-08 03:01:43

    MyAvatars 0.2

    can i ask something????
    how to configure a network using a command prompt or run???
    plz give me some tips for this problem… :twisted:

    Comment by Saman Sadeghi 2007-09-08 09:20:45

    MyAvatars 0.2

    I think this is what you’re looking for: Set Your IP Address Via Batch File

     
     
    Comment by Tech Bold 2007-09-08 03:51:37

    MyAvatars 0.2

    This will come in handy. :cool:

     
    MyAvatars 0.2

    [...] Shutting down the computer via the command prompt is one of my favorite tricks! This time, I’ll show you how to schedule a reboot as a task! [...]

     
    Comment by Sigmund 2007-09-25 14:41:20

    MyAvatars 0.2

    hey, i got some questions, when you shut down a computer remotely, like shutdown -s -m \\desktop, how do u get the computers name, and how do u get administrator access if u dont have it? Oh and yea it is realy funny to mess with people with this stuff, like when u send em a message on there comp (net send * ” “) that sais something like “Massive system failure”. man they freak out…..

    Comment by Saman Sadeghi 2007-09-27 22:11:54

    MyAvatars 0.2

    To find the computer’s name, walk to that machine and hit the Windows Key+Pause/Break, then click the “Computer Name” tab! Look for: “Full computer name”

    As for administrative access - that’s kind of the point, you need to be given access, you can’t just take it…

     
     
    Comment by Anjan 2007-11-06 00:10:17

    MyAvatars 0.2

    Hi…. Neeed Help…….. how to access other computer drive from command prompt (Not from My network Places)…… Please do reply……

    Regards,

    Comment by Saman Sadeghi 2007-11-08 21:04:36

    MyAvatars 0.2

    Is this a local drive? Just type the driver letter….

     
     
    Comment by Trey 2008-02-19 18:17:05

    MyAvatars 0.2

    I’m going to be complete honest here. I’m looking for ways to simply mess with the computers at school. Recently, I realized I can open command prompt with a batch file (it was blocked if I tried to run it normally). That being said, I think I might be able to get this remote shutdown thingy to work. However, I encountered problems with Net Send. If anybody could help me out with netsend or with anything that I would consider “fun” (nothing malicious wanted), please let me know.

     
    Comment by Sid 2008-03-04 02:13:43

    MyAvatars 0.2

    Is there a command I can use automatically delete “xpicleanup.dat” when windows xp shutsdown?
    If any body can come up with one, what is the command and were would I place the command?

     
    Comment by sandy reddy 2008-03-09 12:00:43

    MyAvatars 0.2

    yeah it s grt
    but if i want to shut down the system after few minutes r after an hour then?????

    Comment by Saman Sadeghi 2008-03-09 14:56:23

    MyAvatars 0.2

    Then just change the time after the “-t” variable. The following is 60 seconds:
    shutdown -s -t 60
    The next one would be five minutes (60 seconds x 5 minutes):
    shutdown -s -t 300

     
     
    MyAvatars 0.2

    [...] Windows Tip: Shutdown Your Computer With The Command Prompt - 10,529 Views [...]

     
    Comment by robert 2008-03-29 01:26:59

    MyAvatars 0.2

    just want to ask a few things about this topic:
    1 i cant get it to work because my computer wont notice my sisters laptop on the network
    2 can i work if im not using a server
    3 thanks for this if i can get it to work like i can on my computer this will be the best thing by april 1st
    thanks my email is EMAIL ADDRESS REMOVED

    Comment by Saman Sadeghi 2008-03-29 09:51:44

    MyAvatars 0.2

    Well, there are a few things you can try:

    1. Are both machines on the same workgroup?
    2. Do you have an account on both machines?
    3. Do you know the Administrator’s password?
     
     
    Comment by mashael 2008-04-02 06:09:24

    MyAvatars 0.2

    you got some really cool blogs here i am new to this so anything that will help with anytrhing will be cool where do u thing i should start from thanks

     
    Comment by john 2008-04-15 21:37:04

    MyAvatars 0.2

    is it possible to tell it to shut down in like 30 mins or 1 hour?
    cause when i tried shutdown -s -t 2100 (which is like 35 mins i think)
    some explanations came up saying the valid range is 0-600, which is up to 10 mins.
    is it possible to extend this?

    thanks

    Comment by Saman Sadeghi 2008-04-16 11:33:30

    MyAvatars 0.2

    I’ve never tried such a long variable but if you’re getting an error, I would guess not. You can however, use the Task Scheduler to shut down the computer at a later time.

     
     
    Comment by hp 2008-04-16 12:01:40

    MyAvatars 0.2

    my laptop does not do any of the commands (maybe im typing them wrong. waht im doing is only -r. is that the way to do it?)
    can i use this at school even if its not on the administrator account?

    Comment by Saman Sadeghi 2008-04-16 12:39:42

    MyAvatars 0.2

    The correct usage would be:
    shutdown -r
    Yes, you do need to be an administrator.

     
     
    Comment by ryan 2008-04-21 18:26:55

    MyAvatars 0.2

    hei can you help me plz, im on a network with my mom sis and bro, i want to shutdown my bro’s computer tho, how do i do that? ive tried what it says to do to “shut down a remote computer” and it dsnt work, it jz tells me all the switches, ik his login info for his pc if that helps….? i really wana know how to do this cuz sometimes hell shutdown my internet so then i want to shutdown his pc before he can do that

    thxxx

    Comment by Saman Sadeghi 2008-04-22 08:15:03

    MyAvatars 0.2

    I can’t say that I condone the use of this for a prank (or the use of terrible grammar), but here are a few things you need to check:

    1. Are both machines on the same workgroup?
    2. Do you have an account on both machines?
    3. Do you know the Administrator’s password?
    4. Can you access the remote computer through the network?
     
    Comment by 2Perfect 2008-04-22 13:42:44

    MyAvatars 0.2

    next time it happens tell your mom :) make it sound worse than it is, and he might just get grounded ahaha :P And that hurts more than shutting off his pc, which he can easily turn back on.

    2Perfect’s last blog post: Demonoid Returns (better than Batman’s)

     
     
    Comment by ryan 2008-04-22 14:21:26

    MyAvatars 0.2

    i beleive we are on the same network, but no i dont hav an account on both machines, jz on mines but ik his login info.; the password or the NETWORK? if so yes; idk bout #4 but ik that like if he wants a song i put it in my shared files and he gets it off his pc so we must be lke connected…? and i wanna piss him off 2perfect :)

    Comment by Saman Sadeghi 2008-04-22 14:26:49

    MyAvatars 0.2

    Both computers should be on the same Workgroup, you need to know an administrator’s credentials for the remote machine and the remote machine needs to have the Local Security Policy setting for Network Access: Sharing and security model for local accounts set to Classic.

    Try those items.

     
     
    Comment by ryan 2008-04-22 15:00:04

     
    Comment by ryan 2008-04-22 15:02:44

    MyAvatars 0.2

    also he runs vista, make a diffrence?

    Comment by 2Perfect 2008-04-23 14:28:15

    MyAvatars 0.2

    Yes it probably does. Vista might have a few extra things you’d have to do with permissions and such. Unconfirmed though.

    Also, if you’re running Windows XP Home, I don’t think you can do it (also unconfirmed). You’d have to be running win xp pro. Because I’ve tried this myself and can’t turn off my basement computer at night with a Home pc, but i can do it with an XP pro pc.

     
     
    Comment by ryan 2008-04-23 16:45:27

     
    Comment by ryan 2008-04-23 16:45:49

    MyAvatars 0.2

    well yea im running XP

     
    Comment by aaron 2008-04-25 14:24:31

    MyAvatars 0.2

    Can you shut down a computer at an internet location?

    shutdown -r -f -m \\(domain name) or (IP Address)

    If so, what are the NAT ports I need to have enabled to do this?

    Comment by Saman Sadeghi 2008-04-27 21:04:33

    MyAvatars 0.2

    Sorry, only machines on your current network.

     
     
    Comment by dominick 2008-05-31 15:48:14

    MyAvatars 0.2

    it keeps saying that a required privalige is nedded and i ont have it

     
    Comment by james 2008-06-02 22:25:08

    MyAvatars 0.2

    hey guys i know this has already been answered but how (in details :?: ) do you give rights to yourself.

    the situation is my brother is being a noob and wont go to bed early hence hes being late for classes since he cant wake up. Sooo i want to shut his computer off but cant do so because i dont have the admin rights . Can someone post in details how exactly do i go onto his computer and specifically give myself the rights.?

    Hes using xp and im on vista and i can access his comp in network but no login box comes up?? :!:

    if someone can help me that would be good, you will be makin my bro go to school on time :???: :roll:

     
    Comment by mclovin 2008-06-09 15:21:50

    MyAvatars 0.2

    ?that helped alot but you can use ctrl alt adn del to shut down faster¿

    Comment by Saman Sadeghi 2008-06-09 15:51:38

    MyAvatars 0.2

    True, but you can use the command in programming a batch or command file.