Sunday, July 25, 2010

Shutdown Your Computer with a Batch File

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 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 Task

2.Hit Next in the dialog box that opens.

3.In the second screen, navigate to the location of the file.

4.We’ll set this to only run one time, we can change this later
(in the Advanced Properties) if we want.

5. Enter the time and date you want it to run.

6. In the next screen, enter in the user name and the password.

7. Hit Finish and you’re done!!!

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