windows - Close 2 programs, one after another, with a batch file -
i have 2 programs, , b. made batch file have them open simultaneously, , want have them both close when exit program a.
here's code far:
@echo off cd "c:\prog\test" start a.exe cd "c:\prog\test" start b.exe exit
i can't find tutorial doesn't involve kind of timer. problem is, have no idea how long i'll working them before closing. can help?
something along line.
@echo off start cd "c:\prog\test\" starta.exe && startb.exe :test tasklist /fi "imagename eq starta.exe" 2>nul | find /i /n "starta.exe">nul if "%errorlevel%"=="0" goto active :dead taskkill /f /im startb.exe exit :active timeout /t 10 goto test
so explain.
you start programs, test starta.exe
using tasklist. if task returns errorlevel==0 means running. send waiting section 10 seconds, , go test if starta.exe running. if errorlevel not 0, go directly dead , kill startb.exe
Comments
Post a Comment