The Deployment Guys

Helping to deploy your world automagically...

Robocopy exit codes

Robocopy exit codes

  • Comments 18
  • Likes

Robocopy is a great tool, and I often use it in a deployment project for moving files around; I think the most useful feature it has is the /MIR switch.  It lets you update the contents of a folder, only copying the files that have changed or are missing.

One problem with the use of Robocopy in the task sequence is that it doesn't always return an error code of 0, even if the copy has been successful.  This can give a problem if you have your task sequence set up similar to the screenshot below.  As you can see, I have added the Robocopy command direct to the task sequence, and I have left the default "Success codes" on the options tab.  This works fine for most scenarios, but with Robocopy you might find that your deployment fails stating that Robocopy returned a non-success code, even though the copy appears to have been successful.

 

image

 

There are several ways to fix this, but the way I prefer is to add the additional success codes to the task sequence, that way it will only fail if a genuine error occurs.  So, below I have included a list I compiled of the codes I have come across (I have included the non-success codes I have seen for completion).  Feel free to comment on this post if you can help expand the list!

 

Code Meaning
0 No errors occurred and no files were copied.
1 One of more files were copied successfully.
2 Extra files or directories were detected.  Examine the log file for more information.
4 Mismatched files or directories were detected.  Examine the log file for more information.
8 Some files or directories could not be copied and the retry limit was exceeded.
16 Robocopy did not copy any files.  Check the command line parameters and verify that Robocopy has enough rights to write to the destination folder.

 

I strongly recommend that you use the /LOG parameter with Robocopy in order to create a complete log file of the process.  This file is invaluable for finding out what went wrong.

 

This post was contributed by Daniel Oxley a consultant with Microsoft Services Spain

  • <p>Will this work for adding .dll files to C:\Windows\System32 for Vista?</p> <p>-thanks</p>

  • <p>Yes, you could use robocopy to copy files to the system32 folder. &nbsp;Beware with the /MIR switch though because if you are not careful, you could end up deleting the entire contents of the systm32 folder!</p> <p>HTH,</p> <p>Daniel</p>

  • <p>Thank you for the information, Daniel.</p> <p>I recently discovered another way to push DLLs to the system32 of a target PC, but not sure if it is part of &quot;best practices&quot;.</p> <p>On the Deployment Server (MDT 2008), I drilled down to Distribution$\Control\Image_Name\ &nbsp;and created $OEM$\$$\System32 folder structure.</p> <p>I then placed the additional DLLs in the System32 folder and deployed the image. &nbsp;It worked great!</p> <p>Would this be considered a proper way to deploy DLLs by Microsoft's standards?</p> <p>-thanks</p>

  • <p>There is nothing wrong with doing it this way. &nbsp;However, in my opinion, doing it via the task sequence is a better option because anyone can see what process copied the files. &nbsp;If you do it your way then the next person may have trouble finding the process that copied the files onto the machine, if they do not know about the $OEM method.</p> <p>HTH,</p> <p>Daniel</p>

  • <p>Daniel- Well, you are correct about that- but it makes something I need (want) to automate easier! ;)But I won't.I'll create a task sequence and use a run command to copy.</p>

  • <p>Hi Daniel,</p> <p>Thanks again for the information. &nbsp;I haven't had great success using robocopy lately. &nbsp;How would my command line look for moving .dlls from the deployment server to the target PC system32 folder for Vista?</p> <p>-thanks</p>

  • <p>Hi Charles,</p> <p>Sorry to hear that you have not had much success with Robocopy. &nbsp;Seeing as you are moving files to the System32 folder, I would me more tempted to use XCOPY rather than Robocopy.</p> <p>You could use a simple command like: &quot;xcopy source\*.dll c:\windows\system32&quot; to copy your files.</p> <p>HTH,</p> <p>Daniel</p>

  • <p>When running a new computer task I'd like to know what the right (good) stage is to copy over a custom directory. Also I can't find any documentation that describes how the distribution point is referenced as a variable during install phase.</p> <p>Thanks,</p> <p>Dan</p>

  • <p>Dan,</p> <p>There is no right or wrong answer to your first question, it just depends on your own preference. &nbsp;I prefer to do all my own custom steps once all the apps have been installed, so I tend to add my tasks at the end of the process before the sysprep stages.</p> <p>With regards to your 2nd question, you can use the variable %deployroot% to refer to the distribution share. &nbsp;See this page for some more tips:</p> <p><a rel="nofollow" target="_new" href="http://blogs.technet.com/mniehaus/archive/2007/03/07/adding-custom-tasks-to-bdd-2007-task-sequences.aspx">http://blogs.technet.com/mniehaus/archive/2007/03/07/adding-custom-tasks-to-bdd-2007-task-sequences.aspx</a></p> <p>HTH,</p> <p>Daniel</p>

  • <p>Robocopy’s logging I have found to be very accurate, the issue I have is finding a full complete list of error codes, I have scoured the Internet far and wide to no avail save a copy and paste of the ones listed in the reference guide at the bottom the Robocopy.doc. That list is not complete or entirely accurate for example, the reference manual says: </p> <p>0x00 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.</p> <p>This is not accurate they’re many errors which are failures you would want to know about with in the 0x00 error code such as:</p> <p>ERROR 2 (0x00000002) The system cannot find the file specified.</p> <p>ERROR 3 (0x00000003) The system cannot find the path specified.</p> <p>ERROR 5 (0x00000005) Access is denied.</p> <p>ERROR 6 (0x00000006) The handle is invalid.</p> <p>ERROR 32 (0x00000020) The process cannot access the file because it is being used by another process.</p> <p>ERROR 53 (0x00000035) The network path was not found.</p> <p>ERROR 64 (0x00000040) The specified network name is no longer available.</p> <p>ERROR 112 (0x00000070) There is not enough space on the disk.</p> <p>ERROR 121 (0x00000079) The semaphore timeout period has expired.</p> <p>I would really love to find an unabridged listing of the exit codes so I could modify my script one last time. If Microsoft could put something like this out there I would be most grateful.</p>

  • <p>For: ERROR 3 (0x00000003) Getting File System Type of Source</p> <p>Need to make sure your script maps those network drives in the script. &nbsp;The scheduled task environment does not assume the user running the task has logged in. &nbsp;</p>

  • <p>The robocoy.doc file coming with the Server 2003 resource kit contains the following (complete?) list of return codes for robocopy version XP010:</p> <p>The return code from Robocopy is a bit map, defined as follows:</p> <p>Hex Bit Value Decimal Value Meaning If Set</p> <p>0x10 16 Serious error. Robocopy did not copy any files. This is either a usage error or an error due to insufficient access privileges on the source or destination directories.</p> <p>0x08 8 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further.</p> <p>0x04 4 Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary.</p> <p>0x02 2 Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed.</p> <p>0x01 1 One or more files were copied successfully (that is, new files have arrived).</p> <p>0x00 0 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.</p>

  • <p>VegasRage has the same problems that I have and short of someone posting the information in detail, finding a complete list of error messages - and I emphasize messages since the return codes are clearly documented, is near impossible to find. &nbsp;I think Helge was confused and submitted the information that is included at the beginning of this page.</p> <p>Vegas, here are a few more that I have come across:</p> <p>ERROR 51 (0x00000033) Scanning Destination Directory: Windows cannot find the network path. Verify that the network path is correct and the destination computer is not busy or turned off. If Windows still cannot find the network path, contact your network administrator.</p> <p>ERROR 58 (0x0000003A) Copying NTFS Security to Destination File: &nbsp;The specified server cannot perform the requested operation</p> <p>ERROR 1359 (0x0000054F) Scanning Source Directory: &nbsp;An internal error occurred.</p> <p>ERROR 1359 (0x0000054F) Copying File: &nbsp;An internal error occurred.</p> <p>Hope it helps and isn't too late - if perchance you come across a true list, please post it here :)</p>

  • <p>Hi,</p> <p>I need help on following error message. Anu clues ?</p> <p>009/02/01 23:02:09 ERROR 2 (0x00000002) Time-Stamping Destination File X:\file6568</p> <p>The system cannot find the file specified.</p> <p>Thanks</p> <p>Anup</p>

  • <p>Hi Daniel, could you please help us on solving the below problem.</p> <p>We are using robo copy to deploy our files. The script are written to move files from one directory to another, and if any issues arise in between then we need to stop the process. </p> <p>But our process is getting stopped even if any files getting copied successfully. The reason is robo copy will return error code 1 if successfully coies the file. </p> <p>So we need to stop the process only if the error code is not = to 1 and how to trap it.</p> <p>Thanks.</p>

Your comment has been posted.   Close
Thank you, your comment requires moderation so it may take a while to appear.   Close
Leave a Comment