How do I know my computer's not hibernating anymore?
December 5, 2007 10:12 AM   Subscribe

I'm running XP SP2, and I'd like to setup my laptop to do a couple of things once it comes out of hibernation. Pretty much everything I want to do is scriptable, but I have no idea how to trigger the scripts.

For example, I'd like to test if the power cord is plugged in. If it is, use the powercfg utility to switch the power mode to "Desktop". If, however, I come out of hibernation and the cord isn't plugged in, switch to "Power Saver" mode. Scripting these changes are easy, but how do I find out:

a) If the machine's just come up from hibernation

b) If the power cord is plugged in

c) If I've got a monitor on the external port.

This comes about because whatever state the machine was in when I last put it into hibernation is the state it's in when it comes out. The main problem stems from my using it as a desktop when not on the road. If I hibernate while on the road, and the plug it all up at home, I have to go through a hassle to get it to use the monitor as the primary screen instead of the laptop's screen. It would be much nicer if the machine itself just said "oh, I'm at home, let me setup the monitor and power scheme" (and connect to the VPN, and do this, and do that...etc)

I had found a little utility that would launch applications based on power changes (such as waking up), but I can't find it again. I can survive with just that as I can use the monitor change utility as a basis for doing other things.
posted by Spoonman to Computers & Internet (6 answers total) 2 users marked this as a favorite
 
You want to write a program or script (VBS might be easiest) that uses the Win32_PowerManagementEvent in the WMI stuff.

I've never done it, but this should get you headed in the right direction. I think.
posted by jeffamaphone at 10:22 AM on December 5, 2007


Hibernate trigger.
(Found on the internet, no personal experience, so check for spyware etc)
posted by seanyboy at 10:22 AM on December 5, 2007


I'd like to test if the power cord is plugged in. If it is, use the powercfg utility to switch the power mode to "Desktop". If, however, I come out of hibernation and the cord isn't plugged in, switch to "Power Saver" mode.

Your laptop should be able to select separate power-saving modes for AC and battery power automatically. As for changing the display to an external monitor, there should be a function key for that.
posted by kindall at 12:33 PM on December 5, 2007


Response by poster: Win32_PowerManagementEvent in the WMI stuff

Thanks! That one might be the ultimate goal. I'd seen that one earlier and didn't pay enough attention to the returns.

Hibernate trigger

This is exactly the one I'd seen before. Thanks for that one. That one'll at least get me moving until I can finish up the other stuff.

Your laptop should be able to select separate power-saving modes for AC and battery power automatically

It does, but it doesn't change processor power state at that time (setting it to full Mhz instead of power-saving Mhz). I have a script that does that, I just need to know when to fire it off.

should be a function key for that

There is, but my laptop sits in a locked drawer when it's at my desk at home. In order to use the function key, I have to wake it up, shell open. Then, I plug in the monitor, then switch to the external monitor, close the shell and put it in the drawer. If, for example, I forget to change power mode before doing that, closing the shell puts the machine in standby and I have to start all over again. I have a script that can switch which is the primary monitor, but it needs to know when to run. My ideal is I plug it in, turn it on and close the drawer. Let the computer do the work of setting itself up, it's there to do work, after all! :)

Anyone else looking over, I could still use some help determining if the machine's plugged in or not. :)

Thanks to everyone so far!
posted by Spoonman at 1:00 PM on December 5, 2007


Can I piggyback here and ask what could be used as a hook to tell if the system's been booted as a virtual machine versus in "normal" mode? I have a Bootcamp'd XP where I want some things to happen on start up in one case and not the other.
posted by yerfatma at 1:13 PM on December 5, 2007


Response by poster: I had something like that a long time ago. I had a script that checked in the registry to see if the primary was a "PCNet32", since that's what VMware uses in a VM. Most VM software uses special hardware, so maybe?
posted by Spoonman at 11:38 AM on December 6, 2007 [1 favorite]


« Older If I were recently laid off, I would have a lot of...   |   no quero molly Newer »
This thread is closed to new comments.