Wednesday, April 25, 2007

Restart at HH:MM and then run this script

Every morning I come to work I have to turn my machine on and spend at least 15 minutes starting up the various apps I use to get productive. (There is some issue with the BizTalk schema designer combined with Source Safe that causes Visual Studio to use 100% CPU power for 5 minutes per each schema I open.) I've learned to live with this, but I realized today that it would be really cool if I could do the following:

Create a script, macro or something of the sort that specifies the apps I want to run when I start my machine. Instead of shutting down my machine, specify that I want to do a delayed reboot. Here I should be able to specify how long the delay should be, or what time the machine should come back up. I should also be able to specify my script/macro that would be run when the machine comes back up.

This way I would come in and my computer would be ready to go after a nice clean reboot. Kind of like a coffee pot with a timer. :-)

I know I can somewhat achieve this by hibernating my machine, but I have 2GB of RAM and hibernation rarely works for me. I also like to start the day with a freshly rebooted box.

Any ideas on how this could be done? Would hardware support be necessary or can this be done with software only?

1 comment:

Andy Locoweed said...

I don't think you can code anything to wake or start the computer because there's no processes running during those modes. You'd have to resort to some sort of hardware dongle like a PIC connected via RS232 that gets told when to start/stop the PC, or something that uses Wake On LAN.

For a software solution I think I'd write a service that controls the power up/down stuff and then another app that integrates into the task bar or the context menu that can communicate with the service.
How would it work? Like this:
-the "app" talks to the service and tells it when to shut down as well as allows some parameter modifications (more on that in a sec)
-the service is responsible for both monitoring and activating various power modes
-when "activated" the service would do things like shutdown all hard disks, turn off/blank all monitors, and if available put the cpu(s) into their ultimate power saving mode you could also do fan speed throttling and what-not but I think you get the idea... it's like sleep mode but processes are still running
-you could add in code that would prevent the cpu from waking unless a specific keyboard code is entered (or a time trigger is hit)
-upon wakeup the service loads up a predetermined XML file and executes each "command" such as loading x program, then y program, yadda yadda yadda
-if you want to get really fancy you'd have the service also log you off on activation and then do it's power management stuff, then (because you can't hook the secure desktop) it would start the wakeup routine and launch all your apps while you go make some coffee
-as for parameters you'd have power saving modes, start time(s), log on/off handing options, keyboard hotkey configs, and the ability to modify all the apps that you've configured for launching

The biggest problem is startup because there's no way to interact with the login screen (secure desktop) unless you write a custom GINA and I don't think you want to do that.
If you want automated power up and login you have to sacrifice security and/or design some custom hardware.
Personally I'd go for the fake sleep and automated wakeup with an option to simply check that all the desired apps are running and if they aren't then fire them up. That way if you're done work and you close all your work apps so you can troll for porn you know when you come back in the morning all your apps will be loaded and the computer will be up and running, sitting at the lock screen ready for you to start your day. (I forgot to add that the app should lock the computer after it "wakes" for security)