title: Batch file,executing second command if first command exit
body: <p>I have a batch file, <code>updatesipversion.bat</code> that is calling another batch file, <code>template.bat</code>.</p>
  
  <p><strong><code>updatesipversion.bat</code> code:</strong></p>
  
  <pre><code>set init=empty
  set main=svn propget svn:externals ./3c &gt; install\msbuild\SipBranchDefaultDetailsTemplate.txt 
  set error=update
  set action=empty
  
  call template.bat "%init%" "%main%" "%error%" "%action%"
  
  set init=empty
  set main=install\msbuild\SipBranchDetails.exe
  set error=update
  set action=empty
  
  call template.bat "%init%" "%main%" "%error%" "%action%"
  </code></pre>
  
  <p><strong><code>template.bat</code> code</strong></p>
  
  <pre><code>set /a WAcounter=0
  for %%a in (%*) do set /a WAcounter+=1
  if not %WAcounter%==4 goto :Error
  set WAinit=%1
  set WAmain=%2
  set WAerror=%3
  set WAaction=%4
  set /a WAcounter=0
  
  :WAinitCommand
  IF NOT %1=="empty" %WAinit:~1,-1%
  
  :WAmainCommand
  set /a WAcounter+=1
  IF NOT %2=="empty" %WAmain:~1,-1%
  if %errorlevel%==0 goto :WASuccess
  
  :WAerrorMsg
  IF NOT %3=="empty" echo ERROR in %WAerror:~1,-1% Trying again......
  if %WAcounter% equ 10 goto :Finish 
  goto :WAmainCommand
  
  :WASuccess
  IF NOT %4=="empty" %WAaction:~1,-1%
  exit
  
  :Finish
  exit 
  
  :Error
  echo there must be 4 command line arguments
  exit
  pause
  </code></pre>
  
  <p>When the <code>for</code> command in first call to template.bat call <code>if %errorlevel==0%</code> then it exits
  from <code>:WASuccess</code>, if not it exits from <code>:Finish</code>.</p>
  
  <p>The second time template is not called or other command are not executed.</p>
  
  <p>Please tell me if first command is exited, how to continue with making second template call.</p>
  
  <p>Thanks</p>