So I know from experience that running a valid program from cmd.exe and checking the %errorlevel% will return a 0:
C:\>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:\>echo %errorlevel%
0
Likewise, trying to execute a command that does not exist and then checking for the %errorcode% gives me a 9009:
C:\>idontexist.exe
'idontexist.exe' is not recognized as an internal or external command,
operable program or batch file.
C:\>echo %errorlevel%
9009
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 (http://msdn.microsoft.com/en-us/library/ms681381(v=vs.85).aspx) which, unfortunately, lists 9009 as a DNS error.
Does anyone know where this behavior is documented by Microsoft?