Go Premium for a chance to win a PS4. Enter to Win


PC to send shutdown command to all Windows PC's in room when it detects loss of utility power and is on battery backup power

Posted on 2013-06-14
Medium Priority
Last Modified: 2013-07-03
I have a training room, One BIG UPS (APC) that powers all the trianing PC's. I need the PC that has the one data signal (to know when it is on battery backup power) to send a shutdown signal to the other PC's that are on the battery power, but cant know because of the single datacable.

Any ideas?
Question by:speeDemon
  • 3
  • 3
  • 2
  • +3
LVL 12

Expert Comment

by:Gary Dewrell
ID: 39249249
If you are using powerchute then you can have it execute a script that will remotely issue shutdown commands to your other PC's. You could use Powershell or PSExec or even use Task Scheduler to schedule a remote task to run in x minutes that issues the shutdown command.
LVL 13

Expert Comment

ID: 39249661
LVL 12

Expert Comment

ID: 39249926
If someone is handling the Main PC and comes to know that its running on Battery Backup Power, he can run a script or batch file or use psexec command to shutdown all other PC which are on network. To execute this command you must have to run the Batch with User account which has got Admin access on all the PC. If all those are in Domain then would be much easier.


Not sure if there is any way to detect system has switched from Online Power to Battery Power, through any script which can be scheduled to run every 5 minutes to do the monitoring of the Status.
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 27

Expert Comment

ID: 39289597
you can use the windows events to detect the power change
here is a software that does this and launches actions on power change

you can use it to run a psshutdown command
LVL 15

Expert Comment

ID: 39293570
speeDemon, did you get your answer or are you still looking for advice?
I do this currently but I won't get into the details if you've already been helped...and there are plenty good suggestions above.

Author Comment

ID: 39294723
i have not found a solution yet, no. I am going to try the powersaver codeplex option soon
LVL 27

Expert Comment

ID: 39297024
after a little browsing, i found this vbscript which queries the battery status. sorry, i cannot post the URL : i stupidly lost the page where i found it

it should be fairly easy to modify it to spawn an external psshutdows command or even to script the shutdown of the other computers based on this

strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
Set colItems = objWMIService.ExecQuery("Select * From BatteryStatus Where Voltage > 0")
For Each objItem in colItems
    Wscript.Echo "Battery: " & objItem.InstanceName
    Wscript.Echo "On AC Power: " & objItem.PowerOnline
    Wscript.Echo "Battery is Discharging: " & objItem.Discharging
    Wscript.Echo "Battery is Charging: " & objItem.Charging
    Wscript.Echo "Remaining capacity: " & objItem.RemainingCapacity

Open in new window

you'd need to run it on a regular basis as a job

whatever solution you use, you'd better be careful not to stop all your machines if the AC power gets down for a milisecond

please don't forget to post back because i believe this issue is interesting to many other people (myself included)
LVL 15

Expert Comment

ID: 39297192
I'll tell you what I use, it works very well for me.

I use "winapcupsd" instead of "Powerchute" to monitor my UPS from the PC it's connected to, You can download and install from here:


You should use "psshutdown" or "psexec" to initiate remote shutdown from your UPS connected PC to your other machines. Download the suite of tools from here:


Depending on the remote machine's OS, you may have more success with "psshutdown" vs. "psexec". My script has a sample shutdown command using both methods. Use whichever works best for you.

APCUPSD allows you to run scripts when it detects a power outage (and all other power events too). So what you do is write a script (I attached examples) that remotely sends a shutdown to your other machines during a power outage.  You can also write a script (sample included) to cancel the shutdown process if the power is restored.

See my attached 2 sample text files. I renamed them .txt just to submit here but they are really .bat files. Rename them to .bat for use. You could use my 2 files, but just insert your own machine names and credentials.

My scripts below send a shutdown command to my remote machines, telling them to shut down in 5 minutes (300 seconds).

At the top of the scripts, it says where to place these 2 batch files inside of the \apcupsd\ folder structure.

Let me know if you have questions, problems.

Author Comment

ID: 39298375
ZabagaR, this looks like it will work. Can i get a copy of your configuration file? I can not see the location to specify where to call the script by name on power fail and power resume.

Thank you
LVL 15

Accepted Solution

ZabagaR earned 2000 total points
ID: 39298671
The apcupsd will automatically call those 2 files as long as you put them in the right subdirectory and keep their names. That is by default. At the top of those 2 files I put a comment that says where to put them. Just rename from .txt to .bat. With apcupsd there are a bunch of predefined batch scripts it searches for.....so "onbattery" and "offbattery" are states that apcupsd recognizes and therefore will look for a .bat with those exact names.

If you need more explanation I can do tomorrow. It's actually easier than it first appears. My install of apcupsd is a plain unmodified install...I just had to make the 2 bat scripts and drop them where apcupsd was expecting.

Author Closing Comment

ID: 39298770
Great work ZabagaR. My inital testing was a success. Thanks for the help.

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Utilizing an array to gracefully append to a list of EmailAddresses
There are many software programs on offer that will claim to magically speed up your computer. The best advice I can give you is to avoid them like the plague, because they will often cause far more problems than they solve. Try some of these "do it…
This Micro Tutorial will teach you the basics of configuring your computer to improve its speed. It will also teach you how to disable programs that are running in the background simultaneously. This will be demonstrated using Windows 7 operating…
This Micro Tutorial will give you a basic overview of Windows Live Photo Gallery and show you various editing filters and touches to photos you can apply. This will be demonstrated using Windows Live Photo Gallery on Windows 7 operating system.
Suggested Courses
Course of the Month10 days, 13 hours left to enroll

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question