Last active
June 28, 2022 20:43
-
-
Save vdbsh/84b85a458512a07af4c91227f7ac1f1c to your computer and use it in GitHub Desktop.
This script will launch your executable and terminate it after its window will be closed. Useful for hunting down zombie processes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ECHO off | |
ECHO ++++++++++++++++++++ | |
ECHO + riprunner 1.0 + | |
ECHO ++++++++++++++++++++ | |
rem This script will launch your executable and terminate it after its window will be closed. | |
rem Useful for hunting down zombie processes. | |
rem | |
rem (i) Possible start priorities: LOW, NORMAL, HIGH, REALTIME, ABOVENORMAL, BELOWNORMAL. | |
rem (i) Timeout between checks are set in seconds. | |
SET dir=C:\Program Files\Buggy App | |
SET exe=my_buggy_app.exe | |
SET priority=HIGH | |
SET window_title=Buggy App | |
SET timeout=1 | |
rem =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= | |
ECHO Starting "%exe%" in "%dir%" with priority %priority% | |
START "" /D "%dir%" /%priority% "%exe%" | |
:CHECK_WINDOW | |
FOR /F "tokens=* USEBACKQ" %%F IN (`TASKLIST /FI "WINDOWTITLE EQ %window_title%" ^| FIND /C "exe"`) DO ( | |
SET window_count=%%F | |
) | |
IF "%window_count%"=="0" ( | |
TASKKILL /F /IM %exe% | |
ECHO I'm outta here! | |
) ELSE ( | |
GOTO CHECK_WINDOW | |
TIMEOUT /T %timeout% /NOBREAK > NUL | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment