If you're looking for return codes and are trying to get it consistent regardless of the platform, try to use a temp table rather than a variable:
insert #tmp exec master.dbo.xp_cmdshell '...'
Then query the table for the result. But since SP3 is well established by now I'd recommend to pick a different method of accessing File System objects. You can use WMI interface for it via sp_OAxxx extended stored procedures.
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.