title: Foolproof way to check for nonzero (error) return code in windows batch file
body: <h1>Intro</h1>
  
  <p>There's a lot of advice out there for dealing with return codes in batch files (using the ERROLEVEL mechanism), e.g.</p>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/3452046/get-error-code-from-within-a-batch-file">Get error code from within a batch file</a></li>
  <li><a href="https://stackoverflow.com/questions/4367930/errorlevel-inside-if">ERRORLEVEL inside IF</a></li>
  </ul>
  
  <p>Some of the advice is to do <code>if errorlevel 1 goto somethingbad</code>, while others recommend using the 
  <code>%ERRORLEVEL%</code> variable and using <code>==</code>, <code>EQU</code>, <code>LSS</code>, etc. There seem to be issues within <code>IF</code> statements and such, so then delayedexpansion is encouraged, but it seems to come with quirks of its own.</p>
  
  <h1>Question</h1>
  
  <p>What is a foolproof (i.e. robust, so it will work on nearly any system with nearly any return code) way to know if a bad (<strong>nonzero</strong>) code has been returned?</p>
  
  <h1>My attempt</h1>
  
  <p>For basic usage, the following seems to work ok to catch any nonzero return code:</p>
  
  <pre><code>if not errorlevel 0 (
      echo error level was nonzero
  )
  </code></pre>