command line - Using powercfg to duplicate the currently active power scheme -


I currently run a batch file with a series of powercfg commands to duplicate and rename an active plan the wanted.

Manually, I will do something like this at a command prompt.

  powercfg -getteivescheme  

This will present me the GUID active plan

powercfg-duplicatescheme & lt; Received GUID & gt; & Lt; New GUID & gt;

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

  powercfg -duplicatescheme -getctivescheme & lt; New GUID & gt;  

But since this is not allowed, is there any other way?

OK, first you have to remove the GUID from the output of powercfg Can be done with for :

 for  /f "tokens = 2 delims = :(" %% (in powercfg-getctivescheme ') x Copy %% x  

This will output to the GUID only, you can also save it in any variable:

 For  / f "tokens = 2 Delims = :( Set GUID = %% x in %% x ('powercfg -getiveschecheme')  

You can remove extra space from here (here I am a place in front You have a GUID, you can keep it now:

  set GUID =% GUID: =%  

In your command line above:

  powercfg -duplicatescheme% guid% & lt; new GUID & gt;  

You can only create a new GUID I need to think in the I do not know the included command line program which makes one for you.

NB: Here the code (especially for the part part) assumes that you Do this in a batch file. Directly around the command line, you must use % x instead of %% in for order.


Comments

Popular posts from this blog

c# - ListView onScroll event -

PHP - get image from byte array -

Linux Terminal Problem with Non-Canonical Terminal I/O app -