Most computer users would know that properly shutting down a desktop PC is very important to prevent your files from getting corrupted and it also minimizes the risk of damaging the hard drive. However, there are times when things are just out of your control such as an unexpected power failure or your kid pulling the plug out of the socket which causes a forced shut down. One way to keep your computer running when there is no electricity, giving you enough time to properly shut down your computer, is by using a battery backup known as Uninterruptible Power Supply (UPS).
A more affordable lower range home
based UPS normally has a few battery protected and surge-only outlets but with
only 1 USB connection. The USB is for the UPS to tell the computer how much power is left on the battery so you can
then either use the UPS manufacturer’s software or from the Windows power
options perform a graceful shutdown before the battery is
depleted. This would mean only 1 computer can know when the battery level is
low and auto shutdown the computer but the rest of the computers connected to
the other remaining battery protected outlets won’t know and cannot be
configured to automatically shut down.
In this article we’ll show you a
couple of ways on how you can use one UPS on multiple computers and
automatically shut down all the computers that are connected to that one single
UPS. The technique used in this workaround is actually pretty simple. All you
need to do is get the computer that is connected to the UPS via USB connection
to send out commands which can remotely shut down other computers when the
battery has reached a low or critical level. So the only requirement here is
the computers must be connected via local area network either by
wireless or cable.
In Windows XP, this can be easily
achieved because the operating system allows you to run a custom program when
the battery power level is low. However starting from Windows Vista until the
current Windows 8.1, this useful option has been limited to only allow you to
choose either two actions which is sleep or shut down.
Run
custom program or script when power is low in Windows 7
1. Shutter
Shutter is a very straight forward
scheduling utility that allows you to perform certain actions based on a
selection of events. There is a “Battery Low” event which you can set it to
trigger an event when the battery level drops below specific level.
To run a custom batch file or
program when the battery reaches a low level using Shutter, you’ll first need
to add an event by clicking on the Add button on the event, select Battery Low,
optionally change the percentage of the battery level and click Add. Now click
the Add button from the Action, select Open File and choose the batch file that
you want to run. Click Add and finally the Start button.
Whenever your battery level reaches
5%, Shutter will simply run the custom batch file. It would make sense to
automatically run Shutter on Windows startup which can be done from the General
tab in Options. You will need to select “Autorun at Windows startup/logon” (all
users or current users) and optionally “minimize on start of event monitoring”.
Most importantly, go to Advanced tab and select “Start event monitoring when
application launches” or else the program only starts up but don’t monitor the
event.
The Lite version is free for non
commercial use but is limited to number of events and actions with a nag popup
on program startup. Shutter takes up merely a few megabytes of memory and
nearly zero CPU usage. A portable version is available to download.
2. BatteryDeley
BatteryDeley is another small
program created with AutoHotkey that can be configured to run custom
programs when a battery has reached a certain level. It is not that user
friendly like Shutter because it doesn’t have a graphical user interface and
the configuration is done by manually editing the BatteryDeley.ini file. By
default, BatteryDeley merely plays a sound and display a small popup image when
reaching a certain battery level and when external power is unplugged or
plugged back in.
Configuring BatteryDeley to run a
custom program when reaching a certain battery level is actually quite easy if
you’re familiar with paths in Windows. Open BatteryDeley.ini with your favorite
text editor such as Notepad or Notepad++. The top part of the
configuration file that starts with semicolon are examples and explanations of
what each line does.
Basically you’ll only need to edit
the alertXpct and alertXcmd values where the pct is the percentage of the
battery level and the cmd is the path of the custom program that you want to
run. The screenshot below shows that when the battery level reaches 5%, a
shutdown.bat file will be ran.
BatteryDelay doesn’t have a built-in
option to auto start with Windows so you’ll need to create a shortcut of BatteryDeley.exe
and drop it in your Startup folder.
3. Task Scheduler
This method doesn’t involve using
any third party software but it is kind of a hackish way of accomplishing it
directly from Windows. The trick here is to enable away mode which actually
takes over the sleep mode and use the Task Scheduler to run a program when it
detects a triggering event (Sleep Mode). The reason why we can’t use Sleep Mode
is because it doesn’t create an event but Away Mode does.
To enable Away Mode, simply download
(AwayModeEnabled.reg) and run the registry file which we’ve
created for your convenience. Once you’ve imported the AwayModeEnabled.reg file
to your registry, whenever your computer goes to Sleep, it will enter Away Mode
instead.
Now run Task Scheduler by
simultaneously pressing WIN + R keys and type taskschd.msc followed by
hitting the Enter key. Click on Create Task at the right actions pane
and a Create Task window will open. Give it a name for this task (e.g. Run
program on Low Battery). Go to Triggers tab and click the New button. Enter the
information as shown below.
- Begin the task: On an event
- Settings: Basic
- Log: System
- Source: Kernel-Power
- EventID: 59
- Enabled Checkbox: Ticked
Now to go Actions tab and click on
the New button. For the action drop down menu, select Start a program which should
be chosen by default and click the Browse button to select the batch file or
program that you want to run when battery power level is low.
Go to Conditions tab, uncheck “Start
the task only if the computer is on AC power” and click OK.
Go to Control Panel > Hardware
and Sound > Power Options. Click on the “Change plan settings” for the
selected preferred plan and click “Change advanced power settings”. Expand
Battery > Critical battery action OR Low battery action and select Sleep
for On battery on either options. By default Low Battery Action is at 10% while
Critical is at 5%. Both of these values can be changed in the Power Options
Advanced Settings.
Sending
Remote Shutdown Commands when Battery is Low
Now that you are able to run a
custom script or program when the battery level is low on the newer Windows
operating system, you’ll just need to write a batch file / script that can
remotely turn off multiple computers that are connected to the other battery
protected outlets. You can rely on third party software such as DShutdown, PowerOff, psshutdown/psexec that
supports command line options to do that.
If using DShutdown:
DShutdown.exe /NOW /IP:192.168.1.1
/poweroff /IP:192.168.1.2 /poweroff /IP:192.168.1.3 /poweroff
DShutdown.exe /NOW /poweroff
DShutdown.exe /NOW /poweroff
If using PowerOff:
poweroff.exe poweroff -force -remote
192.168.1.1 -port 3210 -password MyPASS
poweroff.exe poweroff -force -remote 192.168.1.2 -port 3210 -password MyPASS
poweroff.exe poweroff -force -remote 192.168.1.3 -port 3210 -password MyPASS
poweroff.exe poweroff
poweroff.exe poweroff -force -remote 192.168.1.2 -port 3210 -password MyPASS
poweroff.exe poweroff -force -remote 192.168.1.3 -port 3210 -password MyPASS
poweroff.exe poweroff
If using psshutdown.exe:
psshutdown.exe -r -f -u yourusername
-p yourpassword \\192.168.1.1
psshutdown.exe -r -f -u yourusername -p yourpassword \\192.168.1.2
psshutdown.exe -r -f -u yourusername -p yourpassword \\192.168.1.3
shutdown -s -f -t 0
psshutdown.exe -r -f -u yourusername -p yourpassword \\192.168.1.2
psshutdown.exe -r -f -u yourusername -p yourpassword \\192.168.1.3
shutdown -s -f -t 0
If using psexec.exe:
psexec.exe \\192.168.1.1 -u
yourusername -p yourpassword shutdown /s /f
psexec.exe \\192.168.1.2 -u yourusername -p yourpassword shutdown /s /f
psexec.exe \\192.168.1.3 -u yourusername -p yourpassword shutdown /s /f
shutdown -s -f -t 0
psexec.exe \\192.168.1.2 -u yourusername -p yourpassword shutdown /s /f
psexec.exe \\192.168.1.3 -u yourusername -p yourpassword shutdown /s /f
shutdown -s -f -t 0
You’ll only need to copy either one
of the set of commands above to the shutdown.bat file depending on which
program you prefer using perform the remote shutdown. The first three lines are
to shutdown computer from IP address 192.168.1.1 to 192.168.1.3 (you’ll need to
replace the IP addresses with the ones used on your computer) and the last line
is to shutdown the local computer.
Additional Note: You might want to increase the low battery level to 20%
from the Power Options Advanced Settings so that there will be enough time for
all the computers to properly shut down before the battery power runs out.
Important Note: You need to make sure that the total output power capacity
of all the computers connected to the battery protected outlets are not over
the UPS output power capacity. Overloading the output power capacity can
potentially damage the UPS and your computers. As long as the overload warning
light does not turn on, then it should be safe.
No comments:
Post a Comment