Reputation: 7625
For /f "skip=2 tokens=2,4 delims=:()" %%G in ('powercfg -list') do (
Powercfg -setAcValueIndex %%G sub_buttons sButtonAction 0
if "%%H" == " *" Powercfg -setActive %%G
)
Can someone please explain this to me?
I know it's changing the powercfg for a Windows PC. but dont know what it means.
Upvotes: 0
Views: 687
Reputation: 54603
The tokens=2,4
option of the for
command assigns the variables %G
, %H
. Quoting from the documentation:
tokens=x,y,m-n
Specifies which tokens from each line are to be passed to thefor
body for each iteration. As a result, additional variable names are allocated. The m-n form is a range, specifying the mth through the nth tokens. If the last character in thetokens=
string is an asterisk (*), an additional variable is allocated and receives the remaining text on the line after the last token that is parsed.
The script reads a report from powercfg
and looks for certain information, sets one of the profiles to active. As suggested, taking it apart step-by-step would be a good exercise.
Here's a picture showing someone's power configuration:
By using colon and parentheses for delimiters, the parser ignores those (treats them as a gap), so the script would pick (allowing for column-counts...) the one ending with *
("High performance" in the picture). Your picture may differ, of course.
Further reading:
Upvotes: 1