title: NSIS Abort and errorlevel
body: <p>I'm building a simple installer with NSIS, and would like to run it in Silent mode inside a batch script, where in the end I would check the ERRORLEVEL like that:</p>
  
  <pre><code>REM a simple test
  REM get into folder and run the installer
  cd /d my_installer_path 
  my_installer_made_with_nsis.exe /S
  if %ERRORLEVEL% NEQ 0 echo something has gone wrong
  </code></pre>
  
  <p>Now, it seems that my_installer_made_with_nsis.exe always returns <code>%ERRORLEVEL% 0</code> , even when inside the nsi code I explicitly set an error level and exit with Abort.</p>
  
  <p>In my nsi script I use an ErrorHandling function like that</p>
  
  <pre><code>Function ErrorHandler
  IfSilent +2 0
  MessageBox MB_ICONSTOP "$err_msg"
  
  DetailPrint "$err_msg"
  SetErrorlevel 5 ; &lt;---- APPARENTLY DOES NOT WORK
  Abort
  FunctionEnd
  </code></pre>
  
  <p>Then, in my code I call the errorhandler like that:</p>
  
  <pre><code>...
  StrCpy $err_msg "An exception occurred: blah blah"
  Call ErrorHandler
  </code></pre>
  
  <p>I would expect outside in the cmd shell that %ERRORLEVEL% was 5, but it is always 0.</p>
  
  <p>Maybe I got wrong the whole concept of ErrorLevel in NSIS, but in that case is there a way to retrieve from the command shell the exit code of my installer? </p>