How to set power mode programmatically?

Emmett 66 Reputation points


My target device is windows 11 (21H2).

I want to set/get power mode from my app.

I known PowerGetActiveScheme/PowerSetActiveScheme can get/set power scheme like:
Power Scheme GUID: 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)
Power Scheme GUID: 8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c (High performance)
Power Scheme GUID: a1841308-3541-4fab-bc81-f71556f20b4a (Power saver)

And I can use PowerRegisterForEffectivePowerModeNotifications to get current power mode.
But I can not found any function to set power mode.
Best power efficiency
Best performance

And I use "powercfg /list" to check power scheme for each power mode,
the power scheme of these three mode are all 381b4222-f694-41f0-9685-ff5bb260df2e (Balanced)

Is windows support application to set power mode ?

How can I set power mode programmatically?

P.S. My application can run as admin.


Windows 11
Windows 11
A Microsoft operating system designed for productivity, creativity, and ease of use.
8,148 questions
{count} vote

Accepted answer
  1. Limitless Technology 39,351 Reputation points

    Hello Emmet,

    I would like to share the way I do it. Basically with a custom powerplan:

    You first need to create a profile, your master profile, if you will. Then from the command line:

    "powercfg -l" (this will list profiles and their GUIDs)
    copy the GUID for the profile you created
    "powercfg -export c:\YourPowerProfile.pow {GUID}"
    on a target machine, you'll want to run "powercfg -import c:\YourPowerProfile.pow {GUID}"
    Then you need to make it active, so: "powercfg -setactive {GUID}"
    The thing is, you can use the same GUID each time. You can import it with the GUID that was created when you first made the profile.Therefore, since you know the GUID ahead of time, you can script it in a batch file.

    I placed my .pow file on a network share in the same folder as a batch file (only these two files exist in the folder). My batch file looks like:


    md c:\power
    cd c:\power
    copy "\server\share*."
    powercfg -import c:\power\MyPowerConfig.pow 551d289f-0b99-46b9-8914-18830df35155
    powercfg -setactive 551d289f-0b99-46b9-8914-18830df35155
    powercfg -l
    del c:\power*.
    rd c:\power


    I added a powercfg -l to list the current power configs and be sure mine's listed and set to active.

    --If the reply is helpful, please Upvote and Accept as answer--

0 additional answers

Sort by: Most helpful