How to exit multiple apps in a batch file?

    @echo OFF
start /min "" "D:\Games\Devil May Cry 5\DMCVTrainer.exe"
start /min "" "D:\Games\Devil May Cry 5\SSSiyanCollabTU5_1.1_1.CT"
TIMEOUT /t 5
start "" "D:\Games\Devil May Cry 5\DevilMayCry5.exe"
:RUNNING
tasklist|findstr DevilMayCry5.exe > nul
if %errorlevel%==1 timeout /t 1 & taskkill /F /IM cheatengine-x86_64.exe /T % GOTO ENDLOOP
timeout /t 1
GOTO RUNNING
:ENDLOOP
exit /B

How do I add another taskkill for an additional app exe, I've tried this:

if %errorlevel%==1 timeout /t 1 & taskkill /F /IM cheatengine-x86_64.exe /T taskkill /F /IM DMCVTrainer.exe /T & GOTO ENDLOOP

but it then completely stops working, won't close any app.

Upvotes: 1

Views: 223

Answers (1)

user7818749
user7818749

Reputation:

Use a parenthesized code block.

if %errorlevel% equ 1 (
    timeout /t 1
    taskkill /F /IM cheatengine-x86_64.exe
    taskkill /F /IM DMCVTrainer.exe
)

Maybe also consider errorlevel instead of %errorlevel%

if errorlevel 1 (
    timeout /t 1
    taskkill /F /IM cheatengine-x86_64.exe
    taskkill /F /IM DMCVTrainer.exe
)

Upvotes: 1

Related Questions