They are kind of sneaky little beggars, and you have to read between the lines to discover just how sneaky they really are. If you check the destructions for xp_cmdshell
very carefully, you'll see a one line comment at the top that reads:
Note When executing xp_cmdshell with the Microsoft® Windows® 98 operating systems, the return code from xp_cmdshell will not be set to the process exit code of the invoked executable. The return code will always be 0.
The value returned by xp_cmdshell is actually the final executable return code (ERRORLEVEL) returned to the command interpreter.