Tokens=* means it will only get one token,
%%A. This will be the entire line as you've not specified any delimiters.
There will never be a
%%B value with these options.
Also, the
/A switch for Set means Set will deal with the data as a number. If it's a text string, the variable will be set to 0.
A GUID is a Hexadecimal number, and Hex numbers must start with 0x or you'll get an error that it's not a valid number.
If it's mixed text and numbers, and has any math symbols, you can get unexpected results, or errors like missing operand or divide by zero.
In this case, since
%%B doesn't exist, the variable is not defined.
Use this instead:
Code:
For /F "Tokens=4 Delims=: " %%A In ('powercfg -getactivescheme') Do Set _ActiveScheme=%%A
The
powercfg -getactivescheme command only generates one line of output, so
Findstr isn't needed to select one line out of many.
This uses space and
: as delimiters, so the line will be parsed like this (I added the equals sign, it's not part of the output):
- =Power
- =Scheme
- =GUID
- =49ef8fc0-bb7f-488e-b6a0-f1fc77ec649b
- =(Dell
- =Recommended)
You want # 4, so specify Tokens=4
If you just use
: as a delimiter, you'll get this:
- =Power Scheme GUID
- = 49ef8fc0-bb7f-488e-b6a0-f1fc77ec649b (Dell Recommended)
Note the leading space on the GUID. This might cause problems depending on what you are doing with the value, plus you have to remove the text after the GUID.
EDIT: Correction, using just
: parses the line into just two parts, not three
Jerry