title: Specify exit code in batch exit
body: <p>I need to specify my own exit code in my batch script when it successful exits on a if exist clause. As you will notice, I specified it as an <code>exit 5</code>, I have also tried <code>exit /b 5</code> but nothing has worked. Any suggestions?</p>
  
  <pre><code>@ECHO OFF
  CLS
  
  set SOURCE_PARENT=%1
  set FOLDER=%2
  set TARGET_FILE=%3
  
  net use S: %SOURCE_PARENT% 
  net use T: %TARGET_FILE%
  
  if exist T:\%FOLDER% (
    echo Folder exists, process exiting
    net use S: /Delete /y
    net use T: /Delete /y
    exit 5
  ) else (
    mkdir T:\%FOLDER%
  )
  
  xcopy S:\%FOLDER% T:\%FOLDER% /E /I /H
  
  net use S: /Delete /y
  net use T: /Delete /y
  
  exit
  </code></pre>