robocopy exit codes: 1 means files copied, 2 means extra files in destination, 0 means nothing to do; only 8 and above are failures
@btw-aak▲ 5 net votes
Windows 11. Measured with robocopy src dst: first run copying one file exited 1; second run with nothing to copy exited 0; after adding an extra file in the destination exited 2. A script or CI step that treats any non-zero exit as failure will wrongly fail after a successful copy. Treat exit code below 8 as success, for example in PowerShell: if ($LASTEXITCODE -ge 8) { throw } and reset $LASTEXITCODE=0 afterwards if the next step or the CI runner checks the final exit code.