I have a notebook where the battery is only good for a few minutes.
So quite enough power to send the computer to sleep when there is a power outage.
Or if - as has happened once too often - I forget to turn on power before using the notebook.
Sadly I couldn't configure Windows XPs power management so that it sends the computer to hibernate quickly in these cases.
Typically it takes a few minutes before the built in Windows tool realizes battery power is running out, and then it is too late. Crash, hard disk needs recheck, data and work is lost.
That's why HibernateOnPowerFail was created.
Here you can Download the latest version.
Just copy it to the location you want to keep it and run it. It will try to do the job; if possible it installs itself as a system service,
which means it can hibernate the computer without anyone logged in. Note: no copy of the program is created, so you must not move or delete the program once the service is installed.
If install as a service fails, e.g. because you don't have the administrative privileges,
the program just runs as an ordinary application. But then you have to restart it every time
when you log on, or place it into the autostart folder.
Usually double-clicking the exe does what you want, but for more control there are some command line options:
-i: install as service and start service (needs admin rights)
-u: uninstall service (needs admin rights)
-a: run as application
no option: try to run as service; on failure run as application
unknown option: show this help message
If it was installed as a service, you can see it in services.msc:
If it is running as an application, you can end it by restarting your computer or by using taskmgr.exe:
After it caused a hibernation, the following message should appear:
Please note that HibernateOnPowerFail will not work for computers without a battery, especially it will not work for most desktop computers.
HibernateOnPowerFail can not replace a battery. The computer needs some time to hibernate. During this time battery power must be available.
For desktop computers, you probably need some UPS hardware.
However as far as I know those systems do not act as a battery from a Windows operating system point of view, but keep up the external power supply.
So the computer does not know if its power comes from the UPS battery or not, and due to this for most UPS systems HibernateOnPowerFail will not detect power failure.
My guess is that most UPS come with a hibernate utility of their own, which uses a proprietary way of communication with the UPS.
During developement AntiVir occasionally came up with the notion my program looks like a trojan virus or something.
Well, it uses some system functions to install itself, which may be similar to what some malware uses.
Also I went through some hoops to keep the size of the program small using some unusual compiler and linker settings.
Anyway, luckily the final program is not flagged as a virus, and I hope it stays that way.
Finally, as always... the program is supplied as is without any warranties whatsoever, exept for one point:
I assure you the program was written with good intentions only. I hope it works and is of some use for you.
If it is useful, consider to help me and my hobby projects with a small donation:
Or give me some feedback with a message.
For freeware archives, here is a pad.xml description file.