Assuming you have you computer plugged in a UPS, I’ve discovered that you can connect the UPS’s USB port to your computer and, without installing any third-party software, get information about the state of the batteries. Pretty much like if you were using a laptop.
Now, because Windows knows when it’s running on batteries, it can perform a controlled shutdown if the power runs out.
If for any reason the icon doesn’t appear automatically in the taskbar’s notification area, open the taskbar properties dialog and check the Power option in the Notification Area tab.