title: Official MS reference for cmd.exe %errorlevel% 9009
body: <p>So I know from experience that running a valid program from cmd.exe and checking the %errorlevel% will return a 0:</p>
  
  <pre><code>C:\&gt;dir logo.bmp
   Volume in drive C has no label.
   Volume Serial Number is 5283-A7A2
  
   Directory of C:\
  
  05/22/2008  12:43 PM         1,440,054 logo.bmp
                 1 File(s)      1,440,054 bytes
                 0 Dir(s)  71,723,995,136 bytes free
  
  C:\&gt;echo %errorlevel%
  0
  </code></pre>
  
  <p>Likewise, trying to execute a command that does not exist and then checking for the %errorcode% gives me a 9009:</p>
  
  <pre><code>C:\&gt;idontexist.exe
  'idontexist.exe' is not recognized as an internal or external command,
  operable program or batch file.
  
  C:\&gt;echo %errorlevel%
  9009
  </code></pre>
  
  <p>I've been writing batch scripts for years and they have always worked this way.  However, someone has asked questions about compatibility (both forward and backward) of this technique and I can't find any official documentation from Microsoft actually defining 9009 as the errorlevel when a file or program is not found.  The closest I've come is this site (<a href="http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85).aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85).aspx</a>) which, unfortunately, lists 9009 as a DNS error.</p>
  
  <p>Does anyone know where this behavior is documented by Microsoft?</p>