Reputation: 47
I want batch1.bat
to check if batch2.bat
is running. If batch2.bat
is running, I want nothing to happen. If batch2.bat
is NOT running, I want batch1.bat
to kill the process process1.exe
.
In other words, I want batch1.bat
to start batch2.bat
and wait for it to be closed. Once it is closed, I want process1.exe
to be ended.
How would I write batch1.bat
?
Upvotes: 0
Views: 1827
Reputation: 70923
Batch1.cmd
@echo off
echo 1: starting
echo 1: calling batch2
cmd /c "batch2.cmd"
echo 1: back to batch1
echo 1: end batch1
taskkill /im process1.exe /f >nul 2>nul
Batch2.cmd
@echo off
echo 2: starting batch2
echo 2: in batch2
pause
echo 2: leaving batch2
Upvotes: 3