Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

For example, the different power plans I have available on my Dell e6420 are listed as: enter image description here

How can I link these options w/ a keyboard shortcut, such that I could either a) toggle through them, or b) iterate through the plans?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

As I mentioned in my answer here, you can check the GUIDs for the various plans and create separate shortcuts (with keyboard shortcuts) to Windows\System32\Powercfg.exe to activate each plan (pay attention to the Target field below):

1

However, in order to make things easier so you don't have to look up and carefully copy+paste all those GUIDs, I cooked up a couple of batch files for you.

The first one, PowerPlanAlter.bat, will enable you to quickly switch between all available plans on your system using just a number. Running it without an argument will print something like this:

Usage: PowerPlanAlter [Number]

  1 = "Balanced" [GUID = 381b4222-f694-41f0-9685-ff5bb260df2e]
  2 = "High performance" [GUID = 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c]
  3 = "My Custom Plan 1 (Reduced fan speeds)" [GUID = 938ef152-e95f-4aed-acea-e1c8a0f4493f]
  4 = "My Custom Plan 1 (Increased fan speeds)" [GUID = 9d2a75cb-f035-4376-92db-36fa01e271d2]
  5 = "Power saver" [GUID = a1841308-3541-4fab-bc81-f71556f20b4a]

Current power plan = "Balanced" [GUID = 381b4222-f694-41f0-9685-ff5bb260df2e]

You can call it from the command line or create multiple shortcuts to it, one per plan. Here's the code:

@echo off
set pcnt=0
setlocal enableextensions enabledelayedexpansion
for /f "skip=3 tokens=2* delims=:(" %%a in ('powercfg -l') do (
    set /a pcnt+=1
    set tmp=%%b
    if [!tmp:~-1!]==[^)] set tmp=!tmp:~,-1!
    if [!tmp:~-1!]==[*] set tmp=!tmp:~,-3!&& set cp=!pcnt!
    set pname_!pcnt!=!tmp!
    for /f %%c in ("%%a") do set pguid_!pcnt!=%%c
)
echo.
powercfg -s !pguid_%1! 2>NUL
if errorlevel 1 (
    echo Usage: %0 [Number]
    echo.
    for /l %%d in (1,1,!pcnt!) do echo   %%d = "!pname_%%d!" [GUID = !pguid_%%d!]
    echo.
    for /l %%e in (!cp!,1,!cp!) do echo Current power plan = "!pname_%%e!" [GUID = !pguid_%%e!]
) else (
    for /l %%f in (!cp!,1,!cp!) do echo Old power plan = "!pname_%%f!" [GUID = !pguid_%%f!]
    echo.
    echo New power plan = "!pname_%1!" [GUID = !pguid_%1!]
)

The second one, PowerPlanCycle.bat, will enable you to quickly cycle/iterate through all available plans on your system. No arguments required; just create a shortcut to it and every time you run it the next plan in line will be activated (cycling back to the first one after the last). Here's the code:

@echo off
set pcnt=0
setlocal enableextensions enabledelayedexpansion
for /f "skip=3 tokens=2* delims=:(" %%a in ('powercfg -l') do (
    set /a pcnt+=1
    set tmp=%%b
    if [!tmp:~-1!]==[^)] set tmp=!tmp:~,-1!
    if [!tmp:~-1!]==[*] set tmp=!tmp:~,-3!&& set cp=!pcnt!
    set pname_!pcnt!=!tmp!
    for /f %%c in ("%%a") do set pguid_!pcnt!=%%c
)
echo.
set /a np=!cp!%%!pcnt!+1
for /l %%d in (!cp!,1,!cp!) do echo Old power plan = "!pname_%%d!" [GUID = !pguid_%%d!]
echo.
for /l %%e in (!np!,1,!np!) do powercfg -s !pguid_%%e! && echo New power plan = "!pname_%%e!" [GUID = !pguid_%%e!]

If you're calling these via a shortcut and want to see the output, just add a pause command at the end. These work fine on Windows 7 x64, but let me know if you have a problem with them.

(Oh, and just in case you're not too familiar with batch files, just copy+paste the code into Notepad and save as "PowerPlanAlter.bat" and "PowerPlanCycle.bat" respectively, with the quotes.)

share|improve this answer
1  
Also, there's relevant information on this MS KB @ support.microsoft.com/kb/935799 –  jhstuckey Feb 21 '13 at 0:08

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.