There are two program A and B. What I want to do is:
1,Launch program A;
2,Close program A;
3,Launch program B;
4,Close program B;
How can I write the bat file?
My previous work;
A.exe
TSKILL A
B.exe
TSKILL B
However,when I launch the program A. It keeps running and the rest of the bat files doesn't run at all.
Thanks for your help in advance.
Answer
Using START /WAIT A.exe
will start A.exe
and wait for it to terminate before the script continues to execute the next line.
However, if you would like to automatically kill A.exe
after a set time limit, use this:
@ECHO OFF
START /I A.exe
TIMEOUT 10 & REM Waits 10 seconds before executing the next command
TASKKILL /F /IM A.exe
START /I B.exe
TIMEOUT 10 & REM TIMEOUT only works on Windows 7 and later
TASKKILL /F /IM B.exe
PAUSE
No comments:
Post a Comment