Cool Solutions

Power management with ZENworks Configuration Management


January 5, 2010 12:00 am





It’s getting hot in here

Seasonal greetings as this new year folds open to us all. TenPastEight as 2010 will be known has kicked off with a cold start here in the U.K. This morning the car reported that it was a swonickles tingling cold day at -7.5c ( 18.5 F ). Since the cold weather started, our cities have become grid locked with horseless carriages becoming stuck in snow , pilots seeing if a plane would make a good ice skate , trains cowering in tunnels and the only reliable form of transport being a coal powered steam train designed in the 1940s. As those who can’t communicate in more than 140 characters would say, #fail.

As to me, I’m warm thanks to several servers, a workstation and two laptops all providing enough heat to keep several gilders supported on the thermal stream coming out of my open home office window. I’d prefer it if all this silicon didn’t do this as it is costing money, the gilders are causing air traffic control problems with the local airport and all these extra lumps of CO2 will kill the planet.

Could these adding machines run just a bit cooler? My 1990s Texas Instruments calculator doesn’t get this warm. Mind you, the iPhone does when using the WiFi hard.

I digress.

Will a splash of power management help?

All of my laptops and workstations are centrally managed by ZENworks Configuration Management. Lets give it a go with that and see what happens.

The registry problem

First we need to deal with an issue thrown up like a furball from a cat in the middle of a pool of fishy smelling watery vomit. For Windows, power management settings are applied on a per user basis. But Microsoft, in their wisdom, decided that a normal user should not be able to change the required registry keys that store power management policies.

Just to be clear, MSFT decided that power management should be stored for each individual user and then didn’t allow them to change it. Square that circle.

The only way forwards is to change the Access Control List ( ACL ) for the registry key in question which is:-

HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg

To do the modification, we will use subinacl.exe which is part of the Windows resource kit and can be downloaded using this link. Install the downloaded msi file, you’ll be able to find subinacl.exe in

c:\program files\Windows Resource Kits\Tools

To change the permissions, subinacl.exe is run with these parameters all on one line

/noverbose /subkeyreg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg" /grant=users

To run this on my managed devices, I’m going to use a ZCM bundle which I’ll call PrePowerMgt. The bundle will install subinacl.exe and then execute with the parameters to change the registry permission.

Install MSI does exactly what it says, taking the subinacl MSI which I downloaded from Microsoft and installing on the managed device. I could use a Launch Executable action to run subinacl.exe, but I prefer to use a simple batch file. Why? Well it’s easier to test a batch file than run a bundle repeatedly to try out Launch Executable actions. Once the batch file is working ok, either use the Run Script action or transform into a Launch Executable action. I usual go with the former.

Run script performs the execution of subinacl.exe. Here’s the contents of the batch file

@echo on
cd "%ProgramFiles%\Windows Resource Kits\Tools"
subinacl.exe /noverbose /subkeyreg "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Controls Folder\PowerCfg" /grant=users

BTW, subinacle.exe command line is a single line in the batch file.

I need to ensure that the batch file runs as system or administrator so that subinacl.exe can change the permissions. Unless of course your end users have full local administrative priviledges.

Which we don’t do as it is a bad idea.

The bundle will need to run on my Windows XP / Windows 7 machines before the power policies can be applied. I’m going to do this automatically for all Windows computers by using a dynamic group that has Windows OS installed as the membership criteria. I’ll also make sure that the group only contains workstations as I really don’t want my servers powering down to standby. My PrePowerMgt bundle is then assigned to this group.

Power management schemes

Now that’s done, I need to define my power management schemes. First I’ll take a look at where the power typically goes and a quick bit of Google action brings this lovely pie chart.

All of my displays are LCD panels either on the laptops or workstation. If I shut these off after 15 minutes or so of inactivity, it should reduce my power consumption significantly. I’ll also spin down the hard drives after 30 mins and then go into standby after 45 minutes. I’m going to set all of this up in a virtual environment first so that I can easily tweak things to get the exact settings I want and allows me to easily roll back to a clean state. It also not good practice to use live machines for testing. Happily, VMware Workstation 6.5 onwards exposes power management capabilities to its hosted virtual machines. I’ll fire up Windows XP and Windows 7 virtual machines and define the power shemes. Once I’ve done this, I’ll use a built in Windows command to export the scheme , create ZCM bundles to distribute the schemes and uses the same Windows command to import and finally set the scheme active.

Windows XP only has a few options for power management in its control panel applet. I’ve modified an existing scheme to the settings I want and then use the Save As option to give it an unique name. The name will be referenced when exporting, importing and setting active for Windows XP based computers.

To export, powercfg.exe is used. For Windows XP then command is

powercfg /export  <scheme name> /file <export file name>

For my XP power settings, the command I need to run is

powercfg.exe /export ZCM_Home_Office /file c:\ZCM_Home_Office.pow

Windows 7 has the same process, but the details are very different. Power management has lots of settings compared to Windows XP. For example, Windows 7 allows you to define how system cooling, USB devices, power buttons, wireless all impact power management. I’m just going to stick with the same areas as my Windows XP scheme.

The export is very different. First I need the GUID for my new power scheme.

powercfg /list

Then export with

powercfg /export <file name> <Scheme GUID>

In my case, this looks like

I now have everything I need to create the bundles that will apply the power schemes. All bundles will do the same set of actions but use different parameters with powercfg.exe to import and then set the power scheme active.

Lets look at what’s going on for each action

Install scheme to temp folder: Install file action

Does exactly what it says, places the scheme into the local temp folder. This will be referenced by using the environmental variable TEMP. Make sure that this action runs as the logged in user.

Import scheme: Launch executable action

This requires different actions for Windows XP and Windows 7. For Windows XP it is just a case of running

powercfg.exe /import <scheme name> /file <scheme file name>

Windows 7 is slightly more involved.

Powercfg.exe /import <scheme file name>  <GUID>

Use the GUID from the export performed previously or make one up. In either case, write it down as it is needed to set the scheme active.
For both it is critical that the action runs as the logged in user and the action waits for the command to finish before proceeding or you end up trying to set an non-existent scheme active.

Set scheme active: Launch executable action

Again this requires different actions for Windows XP compared to Vista / Windows 7. For Windows XP it is just a case of running

powercfg.exe /setactive <scheme name>

Windows 7 needs the GUID used when the scheme was imported

Powercfg.exe /setactive  <scheme GUID>

You could use a Run Script action with a batch file just like I did earlier on to run subinacl.exe. I leave that choice up to you.

I’ve created one bundle for Windows XP and another for Windows 7 using the description fields to list what the power scheme does. The bundle names reflect the name of the power scheme and the applicable OS type.

Now onto the assignment for which I’m going to use dynamic groups again. There is already a dynamic group for Windows XP workstations as standard, but not for Windows 7. The latter group is straight forward to create.

Following a ZCM agent refresh on each OS using zac ref, looking in the Control Panel on Windows XP and Windows 7 virtual machines reveals that my power scheme is active. Now I can rollout to my live product machines.

Future plans and the to-do list

That’s really the basics of applying power schemes with ZCM. I could have different power schemes running at various times using bundle launch actions to run at schedule times. Power schemes could be per user using User sources. It might also be possible to have one bundle that does everything across all OS versions.

The to do list really features reporting back on what power scheme is active and what that power scheme contains. This is something that I’ll start researching and post at a later date.

Since I’ve done this, the home office seems cooler. Or maybe that’s due to the cold temperatures outside 😉

3 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 53 votes, average: 4.67 out of 5 (3 votes, average: 4.67 out of 5)
You need to be a registered member to rate this post.

Categories: Uncategorized


Disclaimer: This content is not supported by Micro Focus. It was contributed by a community member and is published "as is." It seems to have worked for at least one person, and might work for you. But please be sure to test it thoroughly before using it in a production environment.


  1. By:aphilp

    To simplify the model slilghtly, you could just use the command line interface.

    This should mean you would only need one bundle for Win7 and WinXP (assuming you wanted the same settings). Also you wouldn’t need to set up a policy on a machine of each OS type and export the settings to a file.

  2. By:samadamssmith

    amazing information for me. never think that would could be