The OS Wars (Vista vs. OSX) Google Maps + In-N-Out Burgers Mashup

Windows Tip: Shutdown Your Computer With A Batch File

Written by Saman Sadeghi on January 21, 2007 Add comments

Why Shut the Computer Down Later?

I have my computer set to defragment itself at 2am but I don’t want it running all night! So, I wrote a batch file that will shutdown the computer and set a Scheduled Task (in the Control Panel) to run the file at 3am.

How To Use The Task Scheduler To Shut the Computer Down At A Later Time

Create a new batch file and write a shutdown command. All you really need is:

cd\
shutdown -s -t 60

I set the “-t” switch just in case I am on the computer and need to cancel it (I shouldn’t be on it at 3am, but you never know). At this point, you should test the file to make sure it’s working.

Save the file, I prefer to save my batch files in the Programs Files folder in the c:\ drive. They are program after all!

Schedule The Task

  1. Navigate to: Control Panel -> Scheduled Tasks -> Add Scheduled TaskThe Task Scheduler in The Control Panel
  2. Hit Next in the dialog box that opens.
  3. In the second screen, navigate to the location of the file.Locate the Batch File
  4. We’ll set this to only run one time, we can change this later (in the Advanced Properties) if we want.Set the Repetition Amount
  5. Enter the time and date you want it to run.Set the Scheduled Time
  6. In the next screen, enter in the user name and the password.Input Your User name and Password
  7. Hit Finish and you’re done!
    Complete the Schedule

You can go into the Advanced Properties, but you don’t really need to.

Start Slide Show with PicLens Lite PicLens
This post is filed in: Command Prompt, Windows Tips And Tricks and has been viewed 5,768 views times.

The OS Wars (Vista vs. OSX) Google Maps + In-N-Out Burgers Mashup

Megaman Loves These Related Posts:


Megaman
  • Windows Tip: Log Off Your Computer With A Shortcut
  • Shutdown Multiple Windows Machines From The Command Prompt
  • Reset Your IP Address Via Batch File
  • Windows Tip: Shutdown Your Computer With The Command Prompt
  • Windows Tip: Batch Files


  • RSS feed | Trackback URI

    10 Comments »

    MyAvatars 0.2

    [...] trick is very similar to shutingdown your computer with a batch file, we just need to change the switch that we pass! More information on the shutdown command and [...]

     
    Comment by Chief 2007-05-09 09:31:39

    MyAvatars 0.2

    THANKS FOR THIS

     
    Comment by Zeynel 2007-07-31 13:25:01

    MyAvatars 0.2

    And to cancel shutdown countdown enter this at Start | Run or at cmd prompt:

    shutdown -a

    Comment by Saman Sadeghi 2007-07-31 22:47:51

    MyAvatars 0.2

    You’re right - Thanks for the tip!

     
     
    Comment by Romeo 2007-10-04 02:46:15

    MyAvatars 0.2

    it dos not work in XP

    Comment by Saman Sadeghi 2007-10-04 10:56:30

    MyAvatars 0.2

    It absolutely works in Windows XP Pro - I haven’t checked “Home” because it’s a joke - also, check to make sure that you followed the directions correctly!

     
     
    Comment by brnaodn 2007-11-20 20:33:25

    MyAvatars 0.2

    yeha it doesnt work in home
    i have it and it says it couldnt be done

    Comment by shawn clarady 2008-03-09 12:08:49

    MyAvatars 0.2

    It dose work in home. I am using it now.

     
     
    Comment by jaunda 2008-02-28 03:37:31

    MyAvatars 0.2

    the easiest way to solve such a defrag-problem is to run the defrag with a batchfile, and then to let the computer shut down by the same batch.

    could look like this:

    @echo off

    defrag c: -f
    defrag d: -f
    defrag e: -f
    .
    .
    .
    defrag xy: -v

    shutdown -s -t 5

    first it defrags the c-drive, after that the d-drive …blah blah
    the ‘-f’ forces to do the defrag, a ‘-v’ instead is for ‘volunteer’. then windows only defrags, when it is needful. (if it is not needful, it makes strange errors, which are absolutely harmless) so the ‘-f’ is better.

    after having defrag’d the drives windows shuts itself down. in this case here after 5 seconds, could be 0 or three, or fivehundred…, too.

    sorry for third-class-english,

    jaunda…

    Comment by Saman Sadeghi 2008-04-16 12:03:52

    MyAvatars 0.2

    Though I didn’t see anyone asking about defragmentation, you are right! Also, I did write an article on this as part of my Start Your Day With A Fresh Computer series, which you can read here: Step Three: Automate Hard Drive Defragmentation.

     
     

    Leave a Reply

    Name (required)
    E-mail (required - never shown publicly)
    URI
    Your Comment (smaller size | larger size)
    You may use <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> in your comment.
    The OS Wars (Vista vs. OSX) Google Maps + In-N-Out Burgers Mashup