Powercfg
Control your system's power management from the command line
December 26, 2005
I've written extensively about Windows XP Service Pack 2's (SP2's) useful new features, but one feature that I didn't notice until recently is Powercfg, a command-line tool that lets you control your system's power-management settings. Powercfg has roughly the same functionality as Control Panel's Power Options applet, but—as is often the case with command-line tools—it offers some functionality that you don't get from Control Panel, letting you take power management a bit further. (Powercfg also ships with Windows Server 2003 in its original release, and a less-powerful version appeared in XP SP1.)
Powercfg has many options, so instead of trying to cover every aspect of the tool in this short article, I'll instead offer a couple of cool Command-Line Interface (CLI)-only suggestions: how to control whether Windows dims your laptop's LCD panel and how Windows reduces your CPU's speed to save power.
Laptop Dimming
Laptops have handily outsold desktops for the past 2 years. One of the ways laptops are distinct from desktops is that power management is necessarily central to their design. Although power management saves energy and accommodates portability, its effects can be perplexing. Recently, a friend asked me why his new laptop would dim its screen at seemingly random moments. He wondered how he could make it stop. Laptop screens can be hard enough to read at full brightness.
Many laptops have function keys that let you control brightness, but none let you configure the screen to remain bright all the time. And Control Panel offers no help on the subject. The solution is to simply open a command prompt and type
powercfg /g off /option videodim
The /g switch is a global option that accepts four parameters in addition to videodim. One, wakeonring, is another setting you won't find in Control Panel; as its name suggests, wakeonring enables or disables Windows' ability to wake your computer from standby or hibernation when some piece of hardware is affected by some outside signal (e.g., its modem sensing an incoming call). You can adjust the three other global settings— batteryicon (whether to show the battery icon on the task bar), multibattery (whether to show more than one battery icon, assuming you have more than one battery), and resumepassword (whether to require a password when resuming from standby or hibernation)—from Control Panel.
Processor Downshifting
Have you ever run a quick CPU speed benchmark, only to find that your 1.5GHz mobile Pentium is running at 700MHz? If so, you're seeing the effects of power management. Windows ships with several prebuilt power-management schemes. These schemes are simply collections of settings for when to turn off your monitor and hard disk, when to put the system in standby mode, when to hibernate the system, and so on. Again, a glance at Control Panel reveals these. But what Control Panel doesn't show you is a fifth setting—the processor throttle setting—that lets Windows slow down your processor to save power. The four processor throttle parameters are none, constant, degrade, and adaptive.
None. The none parameter tells the computer not to slow the processor at all, even if it's just burning up cycles and battery power doing nothing.
Constant. The constant option tells the processor to run at the slowest speed possible. That speed can be slow indeed: In the case of the system I'm currently using, the 1.7GHz processor dropped to 600MHz in constant mode. This slowest clock rate—or in power-management-speak, lowest performance state—seems to be defined by the processor's manufacturer.
Degrade. Taking constant a step further, the degrade parameter runs the system at the slowest acceptable clock rate (the same as in constant mode), and to slow things down even more and save more power, employs a feature called stop clock throttling (or linear performance reduction). The stop clock throttling diagrams I've seen suggest that it stops the processor's clock signal altogether, for short periods of time. As you might know, a processor observes a minimum clock rate—in the case of my mobile Pentium, 600MHz. Running the processor at a slower speed reduces its power usage by even more, but that means running it outside the manufacturer's acceptable range of clock speeds. However, by stopping the clock regularly, rather than just slowing it down, the processor still thinks it's getting its minimally acceptable input clock speed, even though it's actually running more slowly than that minimum clock speed. The logical result is even lower power consumption.
Adaptive. The adaptive option senses how much CPU power the system needs, then runs the CPU as slowly as possible to run whatever processes the system is running. The adaptive parameter seems to be the most flexible processor-throttling setting, but exactly how your processor uses the setting will vary with your processor type. Each chip has its own power-management drivers.
So, the four processor-speed values are—in order of decreasing speed and increasing battery life—none, adaptive, constant, and degrade. To control your processor's power-management values, use the command
powercfg /x /processor-throttle-ac
where name of power scheme is portable/ laptop, max battery, home/office desk, or whatever-power-management profile you're using, and setting is none, adaptive, constant, or degrade. That command configures the power setting when your system is plugged into the wall; you would change processor-throttle-ac to processor-throttle-dc to configure the power setting for when you're running on battery. For example, to tell my system's home/office desk power-management profile to use adaptive CPU throttling, I'd type the following two lines:
powercfg /x "home/office desk" /processor-throttle-ac adaptive powercfg /x "home/office desk" /processor-throttle-dc adaptive
If you have a Pentium processor and want to experiment with your power settings' effect on your system's actual clock speed, check out Intel's Processor Identification Utility (http://www.intel.com/support/processors/tools/piu). This tool tells you how fast the chip should run and how fast it's actually running. If you have an AMD processor, check AMD's Web site for several CPU-family-specific utilities that show clock speeds. AMD's helpful PowerNow! Dashboard program (http://www.amd.com/usen/Processors/ComputingSolutions/0,,30_288_ 1276_964,00.html) shows you the speed of your laptop's processor at any moment.
My second laptop is Turion-based, and when the power is set to adaptive mode, I'm amazed by how the CPU speed changes from second to second. Perhaps the most interesting part is that, were it not for the AMD utility, I would never have known that the processor's speed fluctuated so often. In other words, it's remarkable how often we still run on sub-GHz systems and aren't inconvenienced at all.
Wait, There's More
There's a lot more to Powercfg, but I was just happy that it let me shut off LCD screen dimming and helped me more fully understand and control how my system can slow down to save power. My next project will be to build a batch file that I can use to set a system's power settings from the command line—functionality that will save me a lot of trouble when it comes time to build a new server or workstation.
Mark Minasi (http://www.minasi.com/gethelp) is a senior contributing editor for Windows IT Pro, an MCSE, and the author of Mastering Windows Server 2003 (Sybex). He writes and speaks around the world about Windows networking.
About the Author
You May Also Like