I am running a batch to be executed with one of our automated process, inside this batch I am calling for a java command (application). The automated processing should see the final exit code and determine if its success = 0 or not which will be a failure. In this case it does determine that and batch resume to the next line like nothing happened.
Here is the batch
@ECHO Off
SET Talend_Job=%1%
E:
CD E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\
for /f "tokens=2" %%2 in (E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\Results\%Talend_Job%.txt) do (
set LABEL_OR_ID=%%2
goto gotrev
)
:gotrev
echo LABEL_OR_ID is %LABEL_OR_ID%
java -jar E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\TalendTacTasks-1.0.1.jar ^ get_task_status ^ http://dc01talndtlv01.mycompany.loc:8080/org.talend.administrator/ ^ %LABEL_OR_ID%
set exitcode=%ERRORLEVEL%
echo %exitcode%
echo %ERRORLEVEL%
exit /B %ERRORLEVEL%
----------my results log ---------------
C:\Users\Autosysdevsvc>SET Talend_Job=autosys_talend_test_with_error
C:\Users\Autosysdevsvc>E:
E:\>CD E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>for /F "tokens=2" %2 in (E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\Results\autosys_talend_test_with_error.txt) do (
set LABEL_OR_ID=%2
goto gotrev
)
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>(
set LABEL_OR_ID=1529519219417_Y6RLK
goto gotrev
)
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>echo LABEL_OR_ID is 1529519219417_Y6RLK
LABEL_OR_ID is 1529519219417_Y6RLK
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>java -jar E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\TalendTacTasks-1.0.1.jar get_task_status http://dc01talndtlv01.mycompany.loc:8080/org.talend.administrator/ 1529519219417_Y6RLK
ERROR: Execution Status: JOB_ERROR: Job ended with error(s) - Job Exit Code: 1
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>echo Exitcode=
Exitcode=
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>set exitcode=0
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>echo ERRORLEVEL=0
ERRORLEVEL=0
E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts>exit /B 0