Depending on your OS you may also check the environment variable %ERRORLEVEL%