Sign in with
Sign up | Sign in
Your question
Closed

Batch File - Delete All Power Plans w/ PowerCfg

Tags:
  • Programming
  • Command Prompt
  • Power
  • Apps
Last response: in Apps General Discussion
Share
December 2, 2011 3:51:15 PM

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

More about : batch file delete power plans powercfg

Best solution

a b L Programming
December 2, 2011 10:21:50 PM

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:

  1. for /f "skip=2 tokens=2,4 delims=:()" %%G in ('powercfg -list') do (
  2. powercfg -delete %%G
  3. )
Share
December 2, 2011 11:07:33 PM

Best answer selected by eperezjr.
Score
0
Related resources
December 2, 2011 11:08:14 PM

Rusting In Peace said:
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:

  1. for /f "skip=2 tokens=2,4 delims=:()" %%G in ('powercfg -list') do (
  2. powercfg -delete %%G
  3. )


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!
Score
0
December 3, 2011 12:04:41 AM

This topic has been closed by Nikorr.
Score
0
!