2 Servers 1 UPS, Windows 2012 Edition

In a previous post I showed how to shutdown two servers safely using just one UPS with a single communications port. It was pretty straight forward with the comms port connected to a Windows Server 2003 machine.

But doing the same with Windows Server 2012 is much more difficult, since Microsoft decided to remove the ability to run a program on a low battery event from its power management settings. To make things worse I discovered that a bug in Server 2008 and later meant that issuing a Shutdown command from the native power settings would not perform a clean shut down, instead killing the power in a few seconds. This is not good news for RAID arrays and data integrity.

Time for a new solution, and since Microsoft are of no use, help would need to come from a 3rd party. After research and testing answer came from Shutter, a small program that runs as a trigger and event type program for a variety of different scenarios, with battery discharging status being one. Luckily two instances of the program could be run, one to shut down the remote servers and another for the host machine. Importantly the program can also be run as a Windows service, but more on this in the walk through.  here is how it is done:

Download the portable version of Shutter from den4b.com.

In the Windows directory, create a new folder, here it will be named ups.

In that folder create another 2 folders, one will handle the local server shutdown and the other for remote servers.

Copy the contents of the downloaded Shutter zip to both of the folders.

Before opening the program for the first time, create a .bat that will issue commands to shut down servers. Open Notepad and enter the following text:

shutdown /s /f /t 10 /c “Battery Backup Low”

This is for shutting down the host server. To save, select the folder to be used for host shutdown, in the file type menu select All files, and create a file name with it ending in .bat

Do the same for remote server shutdown using this script, and save to the remote folder:

shutdown /s /f /m \\SERVER /t 10 /c “Battery Backup Low”

Replace SERVER with the name or IP address of the other server running on the UPS.

Now go to the local shutdown folder and open Shutter.

In the events box, add battery and choose a trigger percentage and add. In the action box, choose run a program, and locate the .bat file you created for shutting down the host server.


Important: Go to the settings window and copy the following options:

Shutter Options GeneralShutter Settings Advanced

Save settings and the program can now be closed. Repeat these steps to shut down the remote server, it’s essential to set the battery percentage trigger higher for remote server as they will not get the signal if the host server has already shut down, I recommend at least 5% higher as a safety net especially if the UPS battery drains quickly.

As a power outage is an unpredictable event, Shutter needs to be running at all times on the host server, therefore it needs to be ran as a system service. Microsoft did release a tool that could allow any program to run as a service, however it is very basic and will not restart a program if it happened to crash. Lucky a superior utility by the name of NSSM is available that takes this into account, it also has a more user friendly interface to set up services.

Download the latest release of NSSM and place in the main folder created previously, as it needs to be run alongside the Shutter instances.

From a Command Prompt, navigate to the folder holding the program, by using cd, then a space and the full path to the folder, e.g: cd C:\Windows\ups

Type nssm install and enter, and the new service setup screen will appear.cmd nssm

Choose the Shutter program to run, and create a name to the process, additional details can be made in the Description tab.

nssm install

Move to the login tab and select Log on as, then use an account capable of administrator access and password details.

Click create service and its installed, repeat the process for the other shutter program, giving it a different service name.

By default, these newly created services will start when Windows starts, but need to be started manually when first installed. To start them, the simple option is to restart the machine, but much better would be to press the Windows key & R, then type services.msc and click Run. Scroll down the list to the created services, right click on each and choose start.


It’s worth testing to see if it works rather than just hoping it does. And to save the wait for the batteries to discharge its worth raising the trigger values on Shutter to shut down the machines earlier, this also gives the benefit more charge left if the shutdown does not work.

Before opening Shutter to change values, the services need to be stopped. Open services.msc like before and chose stop against the service.

Make the changes in the action box, its recommended to choose somewhere between 70 and 90 percent. Close the programs and start the services back up. Then testing is as simple as unplugging the UPS from the wall, for security the host machine can be left logged on to monitor the remaining battery percentage so you know when the trigger points are happening.