• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 876
  • Last Modified:

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

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
speeDemon
Asked:
speeDemon
  • 3
  • 3
  • 2
  • +3
1 Solution
 
Gary DewrellSenior Network AdministratorCommented:
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
 
ktaczalaCommented:
0
 
SandeepSr System AdministratorCommented:
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
skullnobrainsCommented:
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
 
ZabagaRCommented:
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
 
speeDemonAuthor Commented:
i have not found a solution yet, no. I am going to try the powersaver codeplex option soon
0
 
skullnobrainsCommented:
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
 
ZabagaRCommented:
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
 
speeDemonAuthor Commented:
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
 
ZabagaRCommented:
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
 
speeDemonAuthor Commented:
Great work ZabagaR. My inital testing was a success. Thanks for the help.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 3
  • 2
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now