O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  

Automating Shutdown
This hack allows you to shut down windows at predetermined times with the Task Scheduler

Contributed by:
[03/19/05 | Discuss (12) | Link to this hack]

After buying a new external hard drive to back up my PC, I wanted to set up my system to automatically back up my hard drive and then shut the computer down for the night once a week. This seemed like an easy task until I actually tried to set the Task Scheduler to shut down my computer. No problem getting things to automatically back up, but there didn’t seem to be any way to get Task Scheduler to shut the computer down. I tried pointing the scheduler at the shutdown.exe in the system32 folder, but all I got was a momentary flicker on my screen, and the computer failed to shut down. I then tried to bastardize Hack #6 from the first edition of Windows XP Hacks by creating a shutdown shortcut on the desktop and then pointing the Task Scheduler at that. No dice. All I got was another screen flicker and the computer continued to happily run.

Frustrated, I went to the internet, but all I really there found were sites advertising shutdown programs I had to pay good money for (sometimes quite a bit of money). I thought the idea of spending $20 dollars just to get my computer to turn off seemed like a terrible waste of cash for such a simple request from my operating system. Then I arrived at the idea of using a batch file.

I worked out how to automate the shutdown procedure with a batch file as follows:

1) Go to the Shutdown menu and open the DOS prompt

2) type: "edit powerdown.bat" (without the quotes)

3) you will get a bluescreen interface. At the blinking prompt, just type: "shutdown –s" (without the quotes)

4) save and exit the bluescreen

At this point, you will have a file named "powerdown" in your "Documents and Settings" folder under your user profile. Now all you have to do is go to the "Scheduled Tasks" utility in the "Systems Tools" folder and set up the time and frequency you want the batch file to operate. You can name the batch file whatever you want, but whatever you do, do not name it "shutdown.bat" when you create it because this, for some reason, just makes the file create an endless loop in a DOS window.

I hope this helps out. I can see how learning a little DOS and practicing with batch files can save a lot of money.

--Cedrick May

O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.