execute commands on power event

freelancer91

New member
Local time
6:20 PM
Messages
71
Is there some way to configure Windows 7 to execute commands (such as resolution changing, killing/starting processes and services, etc.) whenever the laptop switches from AC to DC and back? I have been using batterysaver from codeplex.com but it is still in beta and hasn't seen any updates for around 6 months. It is somewhat unreliable and I can't get it to trigger nircmd.exe to lower my resolution when I switch to battery or to raise it when I switch back.

I think my best bet would be Task Scheduler, but I don't know how to make a power event a trigger. Can anyone help?
 

My Computer

Computer Manufacturer/Model Number
Custom Desktop, Dell Studio XPS 1340 laptop
OS
DT and LT: Windows 7 and Fedora 14
CPU
DT: Intel QX9770, LT: Intel P8600
Motherboard
DT: Intel DX48BT2
Memory
DT: 8GB OCZ DDR3 PC3-10666 Gold Edition LT: 4GB DDR3-1066
Graphics Card(s)
DT: BFG Geforce GTX 295 (B), LT: NVidia Geforce 9400M G
Sound Card
DT: Integrated LT: Integrated
Monitor(s) Displays
DT: Acer 23 inch 1920x1080 monitors, LT: 13 inch
Screen Resolution
DT: 3840x1080 LT: 1280x800
Hard Drives
DT: Samsung SpinPoint 1TB HD103UJ 7200RPM HDD+Fantom Drives 2TB 7200rpm External+OCZ Vertex Series 30GB SSD (boot)
LT: Seagate Momentus 7200RPM 320GB 2.5'' HDD
PSU
DT: Rosewill Bronze Series 1000W LT: 6 cell 62837mWh Li-ion
Case
DT:Thermaltake Armor Series LCS, LT:Dell Black Studio XPS 13
Cooling
DT: Custom watercooling setup
Keyboard
DT: Kengsinton PC/Mac LT: Integrated backlit keyboard
Mouse
DT: Logitech USB Optical Mouse LT: Integrated Track Pad
Internet Speed
380KB/s download on a good day...
Other Info
DT: CD/DVDRW Drive: Hp dvd1140, Multifunction front panel w/ 4 USB ports (2 Powered with 5V and 12V), Powered External SATA, 25-in-1 card reader, and audio ports

LT: Integrated Webcam with Microphone array, 8-in-1 card reader
Task scheduler could possibly do it. Under the Triggers tab, events could be created. I don't think that plugging and unplugging creates a task event though. Be aware that under conditions there is an AC power setting.
 

My Computer

Computer Manufacturer/Model Number
Lenovo x200
OS
Win 7 Ent 64 bit
Memory
4GB
Task scheduler could possibly do it. Under the Triggers tab, events could be created. I don't think that plugging and unplugging creates a task event though. Be aware that under conditions there is an AC power setting.

I suppose for somethings I could potentially remove them from the startup sequence and read them into task scheduler, but one of the difficult ones would be changing the screen resolution.

Dell has a utility on the drivers download page that will turn off aero upon switching to battery, but they could have taken it to the extreme by making it also switch the screen resolution to something like 800x600 instead of the native 1280x800.

I have tried getting nircmd.exe to run through the batterysaver utility that I mentioned and switch the resolution, but I can't get it to work. nircmd.exe is a command line utility that among other things can change the screen resolution. Batterysaver can be configured to execute commands on battery switch (with varying degrees of success) but when I try to add arguments, it does work. I don't understand how they want me to put in the arguments.

My next step was to create a batch file that would run nircmd.exe with the arguments that I wanted, then compile it into an exe and then add it to the batterysaver profile. That also didn't work.

I saw that there is a conditions tab, but that will only tell the computer to stop executing something that was already running if it switches to battery power.
 

My Computer

Computer Manufacturer/Model Number
Custom Desktop, Dell Studio XPS 1340 laptop
OS
DT and LT: Windows 7 and Fedora 14
CPU
DT: Intel QX9770, LT: Intel P8600
Motherboard
DT: Intel DX48BT2
Memory
DT: 8GB OCZ DDR3 PC3-10666 Gold Edition LT: 4GB DDR3-1066
Graphics Card(s)
DT: BFG Geforce GTX 295 (B), LT: NVidia Geforce 9400M G
Sound Card
DT: Integrated LT: Integrated
Monitor(s) Displays
DT: Acer 23 inch 1920x1080 monitors, LT: 13 inch
Screen Resolution
DT: 3840x1080 LT: 1280x800
Hard Drives
DT: Samsung SpinPoint 1TB HD103UJ 7200RPM HDD+Fantom Drives 2TB 7200rpm External+OCZ Vertex Series 30GB SSD (boot)
LT: Seagate Momentus 7200RPM 320GB 2.5'' HDD
PSU
DT: Rosewill Bronze Series 1000W LT: 6 cell 62837mWh Li-ion
Case
DT:Thermaltake Armor Series LCS, LT:Dell Black Studio XPS 13
Cooling
DT: Custom watercooling setup
Keyboard
DT: Kengsinton PC/Mac LT: Integrated backlit keyboard
Mouse
DT: Logitech USB Optical Mouse LT: Integrated Track Pad
Internet Speed
380KB/s download on a good day...
Other Info
DT: CD/DVDRW Drive: Hp dvd1140, Multifunction front panel w/ 4 USB ports (2 Powered with 5V and 12V), Powered External SATA, 25-in-1 card reader, and audio ports

LT: Integrated Webcam with Microphone array, 8-in-1 card reader
Back
Top