我已经对此进行了彻底的搜索,但我找不到所有的碎片;
我有:
BatchA runs for loop
Calls BatchB
BatchB runs a SQL script
SQL Script raises error
BatchB gets error, does (exit /b %ErrorLevel%)
Batch A checks for error
我无法完成最后一步,BatchA会响应批次B的退出错误。
我简化了它,我甚至无法让以下工作。如果不工作,我的意思是GOTO语句不会执行。我讨厌批量循环!!!!
BatchA
setlocal enabledelayedexpansion
FOR /L %%i IN (0,1,0) DO (
:: Define variables
CALL SET TEST_NAME=%%TESTS[%%i]%%
CALL SET D_TEST=%%D_TESTS%%\%%TEST_NAME%%
CALL SET D_DB_RAW=%%D_TEST%%
CALL SET P_TEST=%%D_TEST%%\%%TEST_NAME%%.bat
:: Run preparation script
CALL ECHO. && ECHO.
CALL ECHO [INFO] TEST: %%TEST_NAME%%
CALL ECHO ----------------------------------------------------------
CALL ECHO [INFO] PREPARING THE DATABASE
CALL PUSHD %%D_PRE_TEST%%
CALL %%P_PRE_TEST_BAT%% %%D_DB%% %%D_DB_RAW%%
CALL POPD
CALL SET ERR_MSG="Error preparing the database before test: %%TEST_NAME%%"
if !ERRORLEVEL! NEQ 0 GOTO L_ERROR
BATCH B
EXIT /b 1