efficient way to keep checking if a program is still running with a batch script
问题 I would like to write a batch script, and part of the script I want to check if program1.exe is still running. Once program1.exe is no longer running, I want to do something. I can write a while loop to do this, but it will keep checking over and over and use up 100% of one of my cores in my CPU. Is there an efficient way to check? Maybe a hack that checks this condition once a second? Thanks 回答1: Try like this : @echo off Set "MyProcess=Notepad.exe" :start tasklist | find /i "%MyProcess%"