Powercfg Revisited

Control Windows Vista power settings from the command line

Mark Minasi

June 10, 2009

4 Min Read
ITPro Today logo in a gray background | ITPro Today




A few years ago—in "Powercfg" (January 2006, InstantDoc ID 48399)—I introduced powercfg.exe, a tool built into Windows XP SP2 that lets you manage your system's power configuration from the command line. At the time, I explained that Powercfg's two greatest strengths over the Power Options GUI were that you could use it to broadcast a given set of power-management settings to a large number of systems, and that you could use it to control XP's screen-dimming capability.

Since then, Windows Vista has appeared, and the newer OS not only includes power-management control through Group Policy, but the Power Options GUI lets you control when your system dims (or doesn't dim) your screen. So, is Powercfg still useful in the age of Vista? Sure it is! First, I still often need to tweak or interrogate the system about certain power settings, and I typically want to do that from the command line. (Unfortunately, however, the syntax of the Vista and Windows Server 2008 incarnation of Powercfg is significantly different from XP's.) And second—at least in my case—Powercfg helped me solve a laptop mystery.

I do much of my Vista and Windows 7 testing on an inexpensive, no-name laptop, and I like it quite a bit except for one thing: If I put the laptop to sleep and awaken it later, its Ethernet port no longer works. The power LED still lights and the activity LED still flickers, but nary a byte seems to pass through the port, either coming or going. Everything else works fine after waking from sleep, but the necessity to reboot to get my wired Ethernet connection back is a pain.

The manufacturer's online documentation says nothing about the problem, so I thought I'd just gotten a system with a bad Ethernet chip until I ran across the Powercfg -devicequery command. From an elevated command prompt, I typed

powercfg -devicequery wake_from_any



This command inventories the system's hardware and shows what devices are capable of going to sleep and coming back. Guess which component wasn't on the list? If you find that some part of your computer isn't on the list, don't despair: As I understand it, the question of whether something can sleep is typically a question of whether the manufacturer has written a decent driver for it rather than an evaluation of the hardware itself.

Although I find the Vista/Windows Server2008 incarnation of Powercfg more useful overall than XP's version, the new Powercfg has one aspect that needs to be more human-friendly: It's obsessed with globally unique identifiers (GUIDs) rather than friendly English names for power schemes and power settings. For example, suppose you've found (as I have) that working with virtual machines (VMs) in the Power saver power-management setting is a bad idea—the VMs seem to lock up for some reason. You want to delete the scheme altogether. You'd love to just type

powercfg -delete "power saver"



but you can't. Instead, you'd need to type

powercfg -delete a1841308-3541-4fab-bc81-f71556f20b4a



(I'm not suggesting that you actually do this, but it's something that I've found keeps me out of trouble.) As you've probably guessed, that a1841308-3541-4fab-bc81-f71556f20b4a is the the GUID of the Power saver scheme. Note that Powercfg is probably the only Windows utility that works with GUIDs but doesn't need the curly braces around it. You can get a listing of your power schemes and their GUIDs by typing

powercfg -l

That's a lowercase L, not the number 1. You'll find that these GUIDs seem to be uniform across the Windows platform—even on Windows 7 (at least on Beta 1). Once you know how to get a power scheme's GUID, you can easily understand a bunch of Powercfg options. You're already familiar with the delete (-d) option. With the -setactive option, you can switch your system to a particular power option. For example, the command

powercfg -setactive 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c



sets your system to use the High performance power scheme. Similarly, you can discover your system's current power scheme with the command

powercfg -getactivescheme



which returns both the GUID and the English name.

If you want to create a new scheme of your own, you'll find -duplicatescheme and -changename useful. For example, if I want to create a new power scheme that's simply a variant of the High performance scheme, I'd type

powercfg -duplicatescheme 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c
Power Scheme GUID: 77d5b6b8-ea68-4a1f-84e3-71e001ebc159 (High performance) 



The response from the system tells me the GUID of the new scheme and the name, which is still High performance. Having two schemes with the same name would be a bit confusing, so I could then change the name, as follows:

powercfg -changename 77d5b6b8-ea68-4a1f-84e3-71e001ebc159
"Modified high performance"



But that's not all Powercfg can do. Check back next month for more!

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like