Batch Files and Return Codes

4/26/2018 6789 Contributors

When running a batch file package it can be difficult to tell what different return codes mean.  Return codes will have different meanings depending on the commands within the batch file  It's possible that one of the commands in the batch file has a problem running in the background or it may be a normal code which can be treated as a success (Robocopy.exe, for example, uses return code 1 to mean that it successfully copied files).

You can capture the output from the batch file to see if there's an error by adding the following to the Parameters of the package:

> c:\deploy.txt 2>&1

This will redirect all output from the command to a file on the target computer called c:\deploy.txt. You should be able to tell from there what error, if any occurred, and whether you can safely treat any return code as a success.