JRV
JRV

Reputation: 33

CMD prompt - bat file - Taskkill command ignores start /wait

Here's my script in my bat file:

cd "C:\Program Files (x86)\Steam\Steamapps\common\F13game\"

Start F13theGameRemap.exe

cd "C:\Program Files (x86)\Steam\steamapps\common\F13Game\SummerCamp\Binaries\Win64\"

Start /WAIT SummerCamp.exe

Start /WAIT Taskkill /f /im F13theGameRemap.exe

exit

All I want is to run the first program, then the 2nd. When the 2nd program "summercamp.exe" exits, i want the first program "F13thegameremap.exe" to exit.

The way this script works now is that Taskkill immediately ignores the start /wait command of summercamp.exe and closes F13theGameRemap.exe immediately.

How do I fix this?

Upvotes: 1

Views: 3483

Answers (1)

user6811411
user6811411

Reputation:

Something like this:

@Echo off
Cd /D "C:\Program Files (x86)\Steam\Steamapps\common\F13game\"

Start F13theGameRemap.exe

Cd /D "C:\Program Files (x86)\Steam\steamapps\common\F13Game\SummerCamp\Binaries\Win64\"

Set "App2=SummerCamp.exe"
Start /WAIT %App2%

:loop
Timeout /t 1 >NUL
tasklist.exe /FI "ImageName eq %App2%" /NH |find /i "%App2%" >NUL && Goto :loop

Start /WAIT Taskkill /f /im F13theGameRemap.exe

The :loop will check with 1 second delay if %App2% aka SummerCamp.exe is still running.

Upvotes: 4

Related Questions