Run something if battery is (dis)connected - gHacks Tech News

Run something if battery is (dis)connected

It may sometime happen by accident that the power cable connecting the power source to your notebook gets disconnected while you work with the mobile computer. It does not have to be by accident though, maybe you want to use the notebook in a different location without having to save everything and boot again. The problem that comes up in this situation is that the notebook will start running on battery instead, which can be a issue if it was not charged fully in first place. If the notebook gets disconnected from the power source at an inappropriate time, it may happen that it powers down immediately.

Battery Run is a little command line utility that checks if a power cable is connected. Once it notices that the power cable has been disconnected, it starts a user defined action. A second action is run when the notebook is connected to a power source again. You could for instance play a sound if the power cable gets disconnected to notify you that this just happened, or a software that would reduce power consumption.

Usage is straightforward. Download and unpack the file on your hard drive. Use the command batteryrun load-program-when-disconnected load-program-when connected. For example: batteryrun disconnected.wav connected.wav

Batteryrun will play the disconnected.wav file when the power cable gets disconnected, and the connected.wav file when it gets connected again. A icon should appear in the system tray if everything has been setup correctly.

You can obviously run different programs, or even send the program directly into hibernation or sleep mode to save battery until you can connect the PC to a power source again.

Battery Run is a free portable program for the Windows operating system. It is compatible with all recent 32-bit and 64-bit editions of the operating system.

Advertisement

We need your help

Advertising revenue is falling fast across the Internet, and independently-run sites like Ghacks are hit hardest by it. The advertising model in its current form is coming to an end, and we have to find other ways to continue operating this site.

We are committed to keeping our content free and independent, which means no paywalls, no sponsored posts, no annoying ad formats or subscription fees.

If you like our content, and would like to help, please consider making a contribution:


Previous Post: «
Next Post: »

Comments

  1. yair said on January 23, 2008 at 2:39 am
    Reply

    just what i needed, thanks!

  2. duryodhan said on January 23, 2008 at 5:20 am
    Reply

    All of the notebooks I have used, you can see a noticeable difference in screen brightness as soon as the ac power is connected and a sound is also played. A light on the laptop also turns off.

  3. yair said on January 23, 2008 at 12:44 pm
    Reply

    i use an old laptop to run a 3 year unattended time-lapse photography. it is connected to UPS.
    if i have severe power failure i need to run a notification when the ups fails and the battery kicks in.
    i use gcal command line utility to send an sms.
    anyways this is exactly what indeed…

Leave a Reply

Check the box to consent to your data being stored in line with the guidelines set out in our privacy policy

Please note that your comment may not appear immediately after you post it.