Auto shutdown batch file help


  1. Posts : 212
    Windows 7 64bit
       #1

    Auto shutdown batch file help


    Happy new year everyone,

    I'm looking to create a batch file to auto shut down my machine after a certain amount of time. Just want to check if i have got the 1st part of the command right in notepad but i was not sure how i go about putting in a timer for example if my download has 2hrs left i would like to set the batch to run say 2hrs 30mins after running it.


    @echo off

    shutdown /s

    Hope you can help many thanks
      My Computer


  2. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #2

    You need to add the /t xxx switch where xxx is the time delay in seconds. So for 2hrs 30mins, xxx would be 9000. This means that your code should read as follows:

    Code:
    @echo off
    shutdown /s /t 9000
    To cancel before the time elapses, use the following command: shutdown /a

    Shut Down Computer Shortcut - Create

    Abort Shortcut - Create
    Last edited by Brink; 01 Jan 2011 at 11:50. Reason: added links ;)
      My Computer


  3. Posts : 212
    Windows 7 64bit
    Thread Starter
       #3

    Thanks for that mate really appreciate it, do i have to have the cancel command in the batch all the time or do i have to add it in if i decide i dont want the machine to shutdown then run the batch again?

    thanks matey
      My Computer


  4. Posts : 6,285
    Windows 10 Pro X64
       #4

    Click on the Start Orb, and enter shutdown /a to cancel the pending shutdown. It does not belong in the batch file. Alternatively, you could create another batch file with shutdown /a in it and have that on the Desktop next to the one that starts the shutdown.
      My Computer


  5. Posts : 212
    Windows 7 64bit
    Thread Starter
       #5

    cool thanks so much for that mate, +rep for both of you for your kind help
      My Computer


  6. Posts : 9,582
    Windows 8.1 Pro RTM x64
       #6

    You're welcome. :)
      My Computer


  7. Posts : 1,036
    Winbdows 7 ultimate x64 | Ubuntu 12.04 x64 LTS
       #7

    And there's the /r switch for restart. You can also type shutdown ? in a command prompt to view all the switches and their functions..
    Last edited by EzioAuditore; 01 Jan 2011 at 12:07. Reason: EDIT: Oh! My 400th post. ;)
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 09:26.
Find Us