Solved

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
11
755 Views
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?
0
Comment
Question by:speeDemon
  • 3
  • 3
  • 2
  • +3
11 Comments
 
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.
0
 
LVL 12

Expert Comment

by:ktaczala
ID: 39249661
0
 
LVL 12

Expert Comment

by:Sandeep
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.

http://technet.microsoft.com/en-us/sysinternals/bb897553.aspx

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.
0
Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

 
LVL 27

Expert Comment

by:skullnobrains
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
http://batterysaver.codeplex.com/

you can use it to run a psshutdown command
0
 
LVL 15

Expert Comment

by:ZabagaR
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.
0
 
LVL 1

Author Comment

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

Expert Comment

by:skullnobrains
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
Next

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)
0
 
LVL 15

Expert Comment

by:ZabagaR
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:

http://sourceforge.net/projects/apcupsd/files/win-binaries%20-%20Stable/3.14.10/

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:

http://technet.microsoft.com/en-us/sysinternals/bb842062.aspx

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.
onbattery.txt
offbattery.txt
0
 
LVL 1

Author Comment

by:speeDemon
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
0
 
LVL 15

Accepted Solution

by:
ZabagaR earned 500 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.
0
 
LVL 1

Author Closing Comment

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

Featured Post

Simplifying Server Workload Migrations

This use case outlines the migration challenges that organizations face and how the Acronis AnyData Engine supports physical-to-physical (P2P), physical-to-virtual (P2V), virtual to physical (V2P), and cross-virtual (V2V) migration scenarios to address these challenges.

Question has a verified solution.

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

When you start your Windows 10 PC and got an "Operating system not found" error or just saw  "Auto repair for startup" or a blinking cursor with black screen. A loop for Auto repair will start but fix nothing.  You will be panic as there are no back…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

820 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