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
734 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
 
LVL 26

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
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
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 26

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The recent Microsoft changes on update philosophy for Windows pre-10 and their impact on existing WSUS implementations.
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial will teach you how to the overview of Microsoft Security Essentials. This is a free anti-virus software that guards your PC against viruses, spyware, worms, and other malicious software. This will be demonstrated using Windows…
This Micro Tutorial will give you a introduction in two parts how to utilize Windows Live Movie Maker to its maximum editing capability. This will be demonstrated using Windows Live Movie Maker on Windows 7 operating system.

746 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now