How to abort robocopy on first error

16,038

Use the Retries argument and set it to 0:

/R:0

Robocopy will not retry if an error is found and the command is aborted. What you are experiencing is the fact this option is set by default to 1 thousand, or something similar.

As an added note, you can save the retries option to the registry which I believe may be useful in your case. This will save you from having to remember to set it to 0 every time and feels more natural, since you may want to explicitly tell robocopy to retry n times, instead of having to explicitly tell robocopy to not retry.

/R:0 /REG

Use /REG when applying /R: and that setting will be saved to the registry for future use.


If you wish to abort the whole robocopy operation, I'm afraid this isn't possible under robocopy. Not to my knowledge at least.

You will in that case want to use XXCOPY and the /C0 option.


Robocopy philosophy (being a replication tool) stops it from doing this... well, in my view at least until rollover is implemented.

Share:
16,038

Related videos on Youtube

Yuri Astrakhan
Author by

Yuri Astrakhan

Updated on September 17, 2022

Comments

  • Yuri Astrakhan
    Yuri Astrakhan over 1 year

    When using robocopy windows utility, what flags do I set so that robocopy aborts on the very first error it sees, similar to xcopy /dry command?

    I need to mirror two dirs, and on occasion some files would be locked. I do not want robocopy to continue trying to copy files, or override the files that are not locked - rather the very first error should stop the whole copy process.

    UPDATE:

    I already have the /R set to 0 - unfortunately that it only applies to a single file, NOT to the whole copying process. Hence, the first file is ignored (instead of stopping the copying), but subsequent files are copied.