How can I use .bat files to run games with different power plans?


  1. Posts : 2
    Windows 10
       #1

    How can I use .bat files to run games with different power plans?


    Hello,

    I have created two .cmd files where I can change power plans really quick.
    The code in the .cmd files looks like this:

    powercfg /s 381b4222-f694-41f0-9685-ff5bb260df2e
    exit

    This works fine. But now I want to have a .bat file, which activates a power plan until the game is closed.

    For example:

    I want to change the power plan to high performance. Then a game out of origin or steam should start. When I close the game, power plan should switch back to balanced.

    I tried following code, but this still does not work:

    start /b "c:\users"username"\desktop" performance.cmd
    start /d "d:\games\origin" originclientservice.exe
    start /d "d:\games\origin" originwebservice.exe
    start /d "d:games\origin\origin games\mass effect andromeda" masseffectandromeda.exe
    start /b "c:\users"username"\desktop" balanced.cmd

    The game starts, but the balanced power plan is still active. How can I say, that the .bat file has to wait until the game is closed?
      My Computer


  2. Posts : 13,995
    Win10 Pro and Home, Win11 Pro and Home, Win7, Linux Mint
       #2

    Usually putting Pause on the line after a command keeps the .bat file open but the usher has to hit Enter for the file to complete. Don't have a solution for the game program to control that.
      My Computers


  3. Posts : 2
    Windows 10
    Thread Starter
       #3

    I changed code to this and this works but is not optimal:

    start /b "c:\users"username"\desktop" performance.cmd
    start /d "d:\games\origin\origin games\mass effect andromeda" masseffectandromeda.exe
    start /wait "" "c:\users"username"\desktop" balanced.cmd

    But now desktop directory opens and I have to activate balanced.cmd manually after closing the game.
      My Computer


  4. Posts : 5,478
    2004
       #4

    Do you find it makes a difference? Certainly for me games don't run any better using high performance compared to balanced.

    You can't really do this easily (except for clicking on something manually) as the OS doesn't have a trigger for ending a process AFAIK.

    You could write a program to see if d:\games\origin\origin games\mass effect andromeda was running or not and switch power plan.

    Something like this - powershell - How to Correctly Check if a Process is running and Stop it - Stack Overflow but add a pause every 5 seconds or something.

    There would be a minor (probably negligible) impact and may not actually be worth it. You could do it though.

    Technically of course you could put a rocking horse on a Porsche but unless you have a reason to do so it may be pointless.

    I don't find Power Plans make any difference personally as Balanced will take whatever resources it needs anyway.
      My Computer


  5. Posts : 42,944
    Win 10 Pro (22H2) (2nd PC is 22H2)
       #5

    If you really need to do sthg like that you can use e.g. Autohotkey.

    Once the game has been launched, the script (which is still running) runs a loop to test for the presence of the game process, until not present, then restores your original power plan.
      My Computers


  6. Posts : 5,452
    Windows 11 Home
       #6

    You can try Process Lasso, among other things, it changes power profiles.
      My Computer


 

  Related Discussions
Our Sites
Site Links
About Us
Windows 10 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 10" and related materials are trademarks of Microsoft Corp.

© Designer Media Ltd
All times are GMT -5. The time now is 01:54.
Find Us




Windows 10 Forums