Post-构建事件 Visual Studio 2015 | 运行 2个程序,等一个结束杀掉另一个

Post-Build event Visual Studio 2015 | Running 2 programs, waiting for one to end and killing the other

我在创建自定义 post-build 脚本时遇到问题。它会像这样。

解决方案:2个程序(程序A、程序B) 构建顺序设置为程序 A,然后程序 B

程序A运行且永不结束 程序B运行结束 需要关闭程序A

ProgramA 的 PostBuild 事件:@ProgramA.exe(只是冻结并且从未完成构建,因为 ProgramA 永远不会自行结束)

为了进一步澄清我的问题,在 linux shell 格式中应该是这样的。

./ProgramA &
progAPID=$!
./ProgramB &
progBPID=$!
wait $progBPID
kill -KILL $progAPID

对于任何偶然发现此问题的人,以下是我设法解决问题的方法。

@echo off
echo "Running Example Batch"
cd %~dp0/../Example
start /min cmd /c ProgramA.exe
ProgramB.exe
taskkill /f /im ProgramA.exe