我有三个批处理文件,例如parent.bat,child1.bat& child2.bat。父批处理文件调用child1和child2批处理文件。如果让我们说child1.bat以错误代码1退出,那么我的Parent.bat文件不会失败并继续执行child2.bat。
我的问题是如何捕获child1.bat / child2.bat文件的错误代码并相应地使Parent.bat文件失败。
我有以下代码:
REM CHILD1.bat
echo "Executing CHILD1.bat"
call "%WORKSPACE%/tools/CHILD1.bat"
echo "Executed CHILD1.bat"
REM CHILD2.bat
echo "Executing CHILD2.bat"
call "%WORKSPACE%/tools/CHILD2.bat"
echo "Executed CHILD2.bat"