Is it possible to ask ROBOCOPY to exit with an exit code that indicates success or failure?
I am using ROBOCOPY as part of my TeamCity build configurations, and having to add a step to just silence the exit code from ROBOCOPY seems silly to me.
Basically, I have added this:
EXIT /B 0
to the script that is being run.
However, this of course masks any real problems that ROBOCOPY would return.
Basically, I would like to have exit codes of 0 for SUCCESS and non-zero for FAILURE instead of the bit-mask that ROBOCOPY returns now.
Or, if I can't have that, is there a simple sequence of batch commands that would translate the bit-mask of ROBOCOPY to a similar value?
Best Answer
As per here, Robocopy has the following exit code bits that make up the exit code:
Just add if/else statements that
EXIT /B 0
when the return value is 1 or maybe 0, andEXIT /B 1
otherwise. Even if files might have been copied, there's something wrong that would need manual intervention.