Closed Solved

Batch File - Delete All Power Plans w/ PowerCfg

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
4 answers Last reply Best Answer
More about batch file delete power plans powercfg
  1. Best answer
    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]
  2. Best answer selected by eperezjr.
  3. 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:

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


    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!
  4. This topic has been closed by Nikorr.
Ask a new question

Read More

Programming Command Prompt Power Apps