title: Passing the java command exit code to batch ERRORLEVEL
body: <p>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.</p>
  
  <p>Here is the batch</p>
  
  <pre><code>@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&gt;SET Talend_Job=autosys_talend_test_with_error 
  
  C:\Users\Autosysdevsvc&gt;E:
  
  E:\&gt;CD E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts\ 
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;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&gt;(
  set  LABEL_OR_ID=1529519219417_Y6RLK  
   goto gotrev 
  ) 
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;echo  LABEL_OR_ID is 1529519219417_Y6RLK 
   LABEL_OR_ID is 1529519219417_Y6RLK
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;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&gt;echo Exitcode= 
  Exitcode=
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;set exitcode=0 
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;echo ERRORLEVEL=0 
  ERRORLEVEL=0
  
  E:\Operations\BatchServices\Talend\Batches\Talend_AutoSys_Integration\scripts&gt;exit /B 0 
  </code></pre>