Batch File - Delete All Power Plans w/ PowerCfg

Status
Not open for further replies.

eperezjr

Distinguished
Nov 18, 2011
3
0
18,510
0
Can someone assist me in completing this task?

I have an application that imports a custom power plan and then deletes it and adds the old one back one when the application closes. But as I've been debugging, I'll end the debugging and the closing event won't fire. So the power plans never delete when I do that.

Right now, there's hundreds of power plans and I'm deleting them manually. Since you need a GUID to delete them through the command prompt, I was hoping someone could help me enumerate through the GUIDs and delete them.

Thanks
 

Rusting In Peace

Distinguished
Jul 2, 2009
313
0
19,060
34
Don't have a Windows System to write this for you right now I'm afraid but take a look at this for a starter on how to iterate through the result of powercfg -list.

I wouldn't run this code verbatim because I have no idea what the results for powercfg -list looks like but you want to do something like:

[cpp]
for /f "skip=2 tokens=2,4 delims=:()" %%G in ('powercfg -list') do (
powercfg -delete %%G
)
[/cpp]
 

Rusting In Peace

Distinguished
Jul 2, 2009
313
0
19,060
34
Don't have a Windows System to write this for you right now I'm afraid but take a look at this for a starter on how to iterate through the result of powercfg -list.

I wouldn't run this code verbatim because I have no idea what the results for powercfg -list looks like but you want to do something like:

[cpp]
for /f "skip=2 tokens=2,4 delims=:()" %%G in ('powercfg -list') do (
powercfg -delete %%G
)
[/cpp]
 

eperezjr

Distinguished
Nov 18, 2011
3
0
18,510
0


You, sir, are amazing. Although you warned not running it as is, I went ahead and did so. It worked perfectly.

Thanks again, my friend!
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
David___Only Apps General Discussion 0
S Apps General Discussion 4
M Apps General Discussion 3
D Apps General Discussion 2
N Apps General Discussion 1
NoctisLionward Apps General Discussion 2
malavena Apps General Discussion 3
Tom Waller Apps General Discussion 2
P Apps General Discussion 1
S Apps General Discussion 4
A Apps General Discussion 13
Z Apps General Discussion 1
P Apps General Discussion 7
G Apps General Discussion 0
T Apps General Discussion 5
SHADOWSTRIKE1 Apps General Discussion 3
S Apps General Discussion 3
R Apps General Discussion 3
P Apps General Discussion 2
D Apps General Discussion 2

ASK THE COMMUNITY