Solved

Remote shutdown, at shutdown

I have two computers A and B. Both are running windows 7. Computer A is connecter to a battery backup via usb, computer B is powered by the same backup however is not connected via usb. When AC power is lost computer A is told to shutdown. The battery backup software does not support remote shutdown or running a script/batch file. (APC's Powerchute personal edition). I have a batch file that does what I need but I cannot find a way to run it when computer A is told to shut down. Is this possible?
4 answers Last reply Best Answer
More about remote shutdown shutdown
  1. Best answer
    You can probably use PowerShell to query the battery status during shutdown. There are WMI classes for the battery. If the battery state is "discharging," you could run the remote shutdown. I'm going to write a sample script for you later today if I get around to it.
  2. rusabus said:
    You can probably use PowerShell to query the battery status during shutdown. There are WMI classes for the battery. If the battery state is "discharging," you could run the remote shutdown. I'm going to write a sample script for you later today if I get around to it.
    Thanks so i would have to run that on computer A so that whent the battery state changes it would then send the shutdown command to computer B correct?
  3. So, I've found 2 different options. I too have an APC UPS powering 2 computers with PowerChute, but I had to uninstall it to get this first solution to work. I also had to uninstall the APC drivers for the battery backup and use the builtin Windows drivers. You could use this as a shutdown script in PowerShell:
    if ((Get-WmiObject Win32_Battery).BatteryStatus -eq 1) {Stop-Computer -ComputerName "yourRemoteComputer" -Force}

    I'm sure the above could be converted to use WMIC instead of powershell, but I leave that up to you :)

    The second solution is posted on the APC forums, but I didn't test it. http://forums.apc.com/thread/9055

    In my case, neither option really works since my switches are not on a battery backup, just my PCs.

    Hope that helps.

    --Russel

    edit

    for kicks, I converted the above PowerShell into a batch file that uses WMIC. It should run faster than the PowerShell variant:
    
    @echo off
    for /f "usebackq skip=1 eol=" %%i in (`wmic path win32_battery get BatteryStatus`) do (
    	for /f "tokens=1 delims=:" %%j in ("%%i") do (
    		if %%j == 1 (
    			echo Battery is discharging
    			shutdown /s /m \\computername
    		)
    	)
    )
  4. rusabus said:
    So, I've found 2 different options. I too have an APC UPS powering 2 computers with PowerChute, but I had to uninstall it to get this first solution to work. I also had to uninstall the APC drivers for the battery backup and use the builtin Windows drivers. You could use this as a shutdown script in PowerShell:
    if ((Get-WmiObject Win32_Battery).BatteryStatus -eq 1) {Stop-Computer -ComputerName "yourRemoteComputer" -Force}

    I'm sure the above could be converted to use WMIC instead of powershell, but I leave that up to you :)

    The second solution is posted on the APC forums, but I didn't test it. http://forums.apc.com/thread/9055

    In my case, neither option really works since my switches are not on a battery backup, just my PCs.

    Hope that helps.

    --Russel

    edit

    for kicks, I converted the above PowerShell into a batch file that uses WMIC. It should run faster than the PowerShell variant:
    
    @echo off
    for /f "usebackq skip=1 eol=" %%i in (`wmic path win32_battery get BatteryStatus`) do (
    	for /f "tokens=1 delims=:" %%j in ("%%i") do (
    		if %%j == 1 (
    			echo Battery is discharging
    			shutdown /s /m \\computername
    		)
    	)
    )


    Awesome thank you, I will have to try these out when i get off work.
Ask a new question

Read More

Power Command Prompt Computers Windows 7 DOS Batch Shutdown Backup