Automate This: Startup and Shutdown

So I’ve blogged about about tools (Cron, Windows 7 Task Scheduler) to run scheduled tasks.  But what exactly should you schedule?

Today let’s talk about turning your PC on and off. Do you do that manually?

I like to save trees so I power my computer off each evening. But not when I leave the office.  I leave my PC running in case I need to remote into it from home. But after 10pm or so it’s unlikely I’ll be dialing in – so the computer can be turned off – but I’m not driving back to work to hit the power button! :)

First grab a copy of PSTools from SysInternals.  SysInternals has a load a great tools and PSTools itself contains several useful utilities but we’re interested in

PsShutdown – shuts down and optionally reboots a computer

Download PSTools, copy the files somewhere in your system path (C:\Program Files\ etc) so that you can open a command prompt and enter psshutdown and it will run.

Next lets create a simple batch file to call this:


# Uses psshutdown from SysInternals (now Microsoft)

PsShutdown.exe -o -f -k

Save this file as shutdown.cmd

There is a huge list of options available for PsShutdown but we just need a few:

  • -o  Logoff the console user.
  • -f   Forces all running applications to exit during the shutdown instead of giving them a chance to gracefully save their data.
  • -k  Poweroff the computer (reboot if poweroff is not supported).

When I leave the office I usually close everything but the -f will force any open applications to quit, and -k will actually power off the machine.

So I simply setup a scheduled task to run this batch file every day at 10:00PM and save some energy in the middle of the night.

In The Morning

Do you roll into work – power on your PC and then spend 10 minutes gabbing to co-workers and grabbing coffee?  When I roll into the office  my computer is on and ready for me to get to work!  Every computer may not have this option but most Dell’s I’ve used  have an option within the BIOS to power-on the computer at a specific time.   So I have my PC set to crank up at 7:00AM so when I crawl into the office at 8:00 my PC is ready to go.

If your computer BIOS doesn’t have a power-on option and you are using Windows 7 you could possibly put your computer to ‘sleep’ and then use the new Task Scheduler to ‘wake up’ the computer using “Wake the computer to run this task” condition.

In the next entry we’ll talk about automating all the services you have running on your machine.

Recent Related Posts

2 thoughts on “Automate This: Startup and Shutdown

  1. I use Wake On Lan so that I can turn my computer off when I leave the office and still have access to it on-demand; and I use the BIOS scheduled boot to have it ready for me when I get into the office in the morning. Additionally, I set my power saving settings to shutdown after 2 hours of inactivity; in case I’m away from my desk for an extended period of time or forget to shutdown before leaving for the day.

    • I always forget about Wake-On-Lan but that’s a great solution!

      Will have to tinker with the power settings in Windows 7…

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>