SQL Server Agent job returns a failure status after success execution

I have seen this question in forums repeatedly. The job is set to copy some files over the network, the files get copied but the job status shows a failure.

The reason of the failure status is that SQL Server Agent uses the exit code returned by the program to determine if the job step executed successfully and the default value is 0 (zero) for success. You can see this default value (and change it) by opening the job Properties from SSMS and selecting Edit in the corresponding job step. The job type should be "Operating System (CmdExec)" and right before the Command window, you should see it: Process exit code of a successful command: 0

If the program you are using returns anything other than 0 on success, you should change that value to reflect correctly what the status of the job step is after execution.

When I've seen related questions in the forums, in every case the user was using Robocopy to copy the files. Now, Robocopy returns 0 only when no files were copied. If files were copied, the return value is 1.