Using powercfg to duplicate an active power scheme

I need to run a batch file using the powercfg command in order to duplicate the current active circuit and rename it.

Manually, I would do something like this on the command line.

powercfg -getactivescheme

This will give me the GUID of the active circuit.

powercfg -duplicatescheme <GUID obtained above> <new GUID>

Ideally, I would like to do something like this ...

powercfg -duplicatescheme -getactivescheme <new GUID>

But since this is unacceptable, is there any other way?

+3
source share
1 answer

Well, first you need to pull the GUID from the output powercfg. This can be done using the command for:

for /f "tokens=2 delims=:(" %%x in ('powercfg -getactivescheme') do echo %%x

This will simply output the GUID, you can also save it in a variable:

for /f "tokens=2 delims=:(" %%x in ('powercfg -getactivescheme') do set guid=%%x

, ( , :

set guid=%guid: =%

, GUID, :

powercfg -duplicatescheme %guid% <new GUID>

GUID. , .

NB: ( for) , . %x %%x for.

+5

Source: https://habr.com/ru/post/1713374/


All Articles