[SOLVED] Batch file to toggle between balanced and high performance power plan

Status
Not open for further replies.

mcqc

Distinguished
Mar 9, 2010
45
0
18,540
Is it possible to toggle between balanced and high performance power plan using a batch file ?

powercfg -s 381b4222-f694-41f0-9685-ff5bb260df2e

and

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

When set to balanced, toggle to high performance and when set to high performance, toggle to balanced. Without creating 2 differents batch files.
 

mcqc

Distinguished
Mar 9, 2010
45
0
18,540
Code:
@echo off
setlocal

rem Get current value and update it
call :GetToggle
set /P "=+1" < nul >> "%~F0"
set /A "toggle%%=2"

if %toggle% equ 0 (
   echo Set balanced here
) else (
   echo Set performance here
)

goto :EOF

:GetToggle
set /A toggle=0


How to make a toggle switch in batch:
https://stackoverflow.com/questions/50314550/how-to-make-a-toggle-switch-in-batch
This one is working perfectly


Code:
@echo off



set Balanced=381b4222-f694-41f0-9685-ff5bb260df2e

set HighPerf=8c5e7fda-e8bf-4a96-9a85-a6e23a8c635c



for /f "tokens=2 Delims=:(" %%a in ('powercfg /getactivescheme') do for /f %%b in ("%%a") do set Active=%%b



if "%Active%"=="%Balanced%" (Powercfg /s "%HighPerf%") else (Powercfg /s "%Balanced%")

exit
 
Status
Not open for further replies.