I need a bat file of power managment

Discussion forum for all Windows batch related topics.

Moderator: DosItHelp

Post Reply
Message
Author
energysavior
Posts: 6
Joined: 17 May 2016 08:06

I need a bat file of power managment

#1 Post by energysavior » 17 May 2016 08:18

Guys can you help me create a bat file to set my cpu power percentage every time i reboot...
Every time i reboot it turns to default 100% minimum state and 100% maximum state... i need lower, i need to be able to set the values.

i found the instructions for the power managment but i can't do this my self...

can you write for me a bat file to set those values please?

i use win 8 and win 7, two laptops

thanks guys!

aGerman
Expert
Posts: 4678
Joined: 22 Jan 2010 18:01
Location: Germany

Re: I need a bat file of power managment

#2 Post by aGerman » 17 May 2016 15:26

Unfortunately there is no language independent solution.

Code: Select all

@echo off &setlocal
:: German
set "scheme_name=Ausbalanciert"
set "sub_name=Prozessorenergieverwaltung"
set "min_setting_name=Minimaler Leistungszustand des Prozessors"
set "max_setting_name=Maximaler Leistungszustand des Prozessors"

:: English
::set "scheme_name=Balanced"
::set "sub_name=Processor power management"
::set "min_setting_name=Minimum processor state"
::set "max_setting_name=Minimum processor state"


for /f "tokens=2 delims=:" %%i in ('powercfg -l^|findstr /ic:"%scheme_name%"') do for /f %%j in ("%%i") do set "scheme_guid=%%j"
echo scheme_guid       %scheme_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid%^|findstr /ic:"%sub_name%"') do for /f %%j in ("%%i") do set "sub_guid=%%j"
echo sub_guid          %sub_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%min_setting_name%"') do for /f %%j in ("%%i") do set "min_setting_guid=%%j"
echo min_setting_guid  %min_setting_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%max_setting_name%"') do for /f %%j in ("%%i") do set "max_setting_guid=%%j"
echo max_setting_guid  %max_setting_guid%

echo(&echo !!! Do only continue if all four guids were found !!!
pause

:: On battery  min -> 0%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: Plugged in  min -> 0%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: On battery  max -> 100%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 100

:: Plugged in  max -> 100%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 100

pause

I tested with the German settings that work for me.
I also commented the English settings that I expect to work on an English Windows OS.
If you don't know the right names for your language then open a CMD window and run

Code: Select all

powercfg -q|more

in order to find out these names.

Regards
aGerman

energysavior
Posts: 6
Joined: 17 May 2016 08:06

Re: I need a bat file of power managment

#3 Post by energysavior » 19 May 2016 08:23

aGerman wrote:Unfortunately there is no language independent solution.

Code: Select all

@echo off &setlocal
:: German
set "scheme_name=Ausbalanciert"
set "sub_name=Prozessorenergieverwaltung"
set "min_setting_name=Minimaler Leistungszustand des Prozessors"
set "max_setting_name=Maximaler Leistungszustand des Prozessors"

:: English
::set "scheme_name=Balanced"
::set "sub_name=Processor power management"
::set "min_setting_name=Minimum processor state"
::set "max_setting_name=Minimum processor state"


for /f "tokens=2 delims=:" %%i in ('powercfg -l^|findstr /ic:"%scheme_name%"') do for /f %%j in ("%%i") do set "scheme_guid=%%j"
echo scheme_guid       %scheme_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid%^|findstr /ic:"%sub_name%"') do for /f %%j in ("%%i") do set "sub_guid=%%j"
echo sub_guid          %sub_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%min_setting_name%"') do for /f %%j in ("%%i") do set "min_setting_guid=%%j"
echo min_setting_guid  %min_setting_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%max_setting_name%"') do for /f %%j in ("%%i") do set "max_setting_guid=%%j"
echo max_setting_guid  %max_setting_guid%

echo(&echo !!! Do only continue if all four guids were found !!!
pause

:: On battery  min -> 0%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: Plugged in  min -> 0%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: On battery  max -> 100%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 100

:: Plugged in  max -> 100%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 100

pause

I tested with the German settings that work for me.
I also commented the English settings that I expect to work on an English Windows OS.
If you don't know the right names for your language then open a CMD window and run

Code: Select all

powercfg -q|more

in order to find out these names.

Regards
aGerman


many Thenks!

one of this days i'll try to figure out the names... perhaps i'm gonna need more help:)

energysavior
Posts: 6
Joined: 17 May 2016 08:06

Re: I need a bat file of power managment

#4 Post by energysavior » 10 May 2017 09:04

Please someone can make it work for english machine? i still haven't solved the problem...

ShadowThief
Expert
Posts: 1166
Joined: 06 Sep 2013 21:28
Location: Virginia, United States

Re: I need a bat file of power managment

#5 Post by ShadowThief » 10 May 2017 20:06

Those are the English names... (except obviously change the second "Minimum processor state" to "Maximum processor state" but that's clearly just a typo)

Compo
Posts: 600
Joined: 21 Mar 2014 08:50

Re: I need a bat file of power managment

#6 Post by Compo » 11 May 2017 02:24

energysavior wrote:Please someone can make it work for english machine? i still haven't solved the problem...

Did you follow the advice given and change the code provided here:
aGerman wrote:

Code: Select all

@echo off &setlocal
:: German
set "scheme_name=Ausbalanciert"
set "sub_name=Prozessorenergieverwaltung"
set "min_setting_name=Minimaler Leistungszustand des Prozessors"
set "max_setting_name=Maximaler Leistungszustand des Prozessors"

:: English
::set "scheme_name=Balanced"
::set "sub_name=Processor power management"
::set "min_setting_name=Minimum processor state"
::set "max_setting_name=Minimum processor state"


to

Code: Select all

@echo off &setlocal
:: German
::set "scheme_name=Ausbalanciert"
::set "sub_name=Prozessorenergieverwaltung"
::set "min_setting_name=Minimaler Leistungszustand des Prozessors"
::set "max_setting_name=Maximaler Leistungszustand des Prozessors"

:: English
set "scheme_name=Balanced"
set "sub_name=Processor power management"
set "min_setting_name=Minimum processor state"
set "max_setting_name=Maximum processor state"
Please note that there was an error in aGermans code which I have fixed above

energysavior
Posts: 6
Joined: 17 May 2016 08:06

Re: I need a bat file of power managment

#7 Post by energysavior » 11 May 2017 05:50

I copy the code to a text file and then I rename it .bat ... I double click it and it runs, and say

scheme_guid 381b4222-f694-41f0-9685-ff5bb260df2e
sub_guid 54533251-82be-4824-96c1-47b60b740d00
min_setting_guid 893dee8e-2bef-41e0-89c6-b55d0929964c
max_setting_guid bc5038f7-23e0-4960-96da-33abaf5935ec

!!! Do only continue if all four guids were found !!!
Press any key to continue . . .

i press a key and nothing change on the energy plan :/

what i do wrong guys?!

energysavior
Posts: 6
Joined: 17 May 2016 08:06

Re: I need a bat file of power managment

#8 Post by energysavior » 11 May 2017 05:58

this is the actual code i use:
@echo off &setlocal
:: German
set "scheme_name=Ausbalanciert"
set "sub_name=Prozessorenergieverwaltung"
set "min_setting_name=Minimaler Leistungszustand des Prozessors"
set "max_setting_name=Maximaler Leistungszustand des Prozessors"

:: English
set "scheme_name=Balanced"
set "sub_name=Processor power management"
set "min_setting_name=Minimum processor state"
set "max_setting_name=Maximum processor state"


for /f "tokens=2 delims=:" %%i in ('powercfg -l^|findstr /ic:"%scheme_name%"') do for /f %%j in ("%%i") do set "scheme_guid=%%j"
echo scheme_guid %scheme_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid%^|findstr /ic:"%sub_name%"') do for /f %%j in ("%%i") do set "sub_guid=%%j"
echo sub_guid %sub_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%min_setting_name%"') do for /f %%j in ("%%i") do set "min_setting_guid=%%j"
echo min_setting_guid %min_setting_guid%

for /f "tokens=2 delims=:" %%i in ('powercfg -q %scheme_guid% %sub_guid%^|findstr /ic:"%max_setting_name%"') do for /f %%j in ("%%i") do set "max_setting_guid=%%j"
echo max_setting_guid %max_setting_guid%

echo(&echo !!! Do only continue if all four guids were found !!!
pause

:: On battery min -> 0%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: Plugged in min -> 0%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %min_setting_guid% 0

:: On battery max -> 50%
powercfg /setdcvalueindex %scheme_guid% %sub_guid% %max_setting_name% 50

:: Plugged in max -> 50%
powercfg /setacvalueindex %scheme_guid% %sub_guid% %max_setting_name% 50

pause

___________________________________________________________________________
and i receive 2 times invalid parameter... i can't copy paste that

energysavior
Posts: 6
Joined: 17 May 2016 08:06

Re: I need a bat file of power managment

#9 Post by energysavior » 11 May 2017 06:14

with the above code i can set only the minimum ! the maximum does not change plugged and unplugged

some more help here guys :-)

EDIT
thank you all!!! guid guid !


Post Reply