Robocopy exit codes
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.
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
Comments
Anonymous
January 01, 2003
Hi Charles, Sorry to hear that you have not had much success with Robocopy. Seeing as you are moving files to the System32 folder, I would me more tempted to use XCOPY rather than Robocopy. You could use a simple command like: "xcopy source*.dll c:windowssystem32" to copy your files. HTH, DanielAnonymous
January 01, 2003
There is nothing wrong with doing it this way. However, in my opinion, doing it via the task sequence is a better option because anyone can see what process copied the files. 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. HTH, DanielAnonymous
January 01, 2003
The comment has been removed- Anonymous
June 07, 2017
To Anonymous :: June 7, 2017 at 10:04 amYou are mixing exit codes and error codes. It's different things.
- Anonymous
Anonymous
January 01, 2003
Yes, you could use robocopy to copy files to the system32 folder. Beware with the /MIR switch though because if you are not careful, you could end up deleting the entire contents of the systm32 folder! HTH, DanielAnonymous
January 01, 2003
Dan, There is no right or wrong answer to your first question, it just depends on your own preference. 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. With regards to your 2nd question, you can use the variable %deployroot% to refer to the distribution share. See this page for some more tips: http://blogs.technet.com/mniehaus/archive/2007/03/07/adding-custom-tasks-to-bdd-2007-task-sequences.aspx HTH, DanielAnonymous
June 16, 2008
Will this work for adding .dll files to C:WindowsSystem32 for Vista? -thanksAnonymous
June 17, 2008
Thank you for the information, Daniel. I recently discovered another way to push DLLs to the system32 of a target PC, but not sure if it is part of "best practices". On the Deployment Server (MDT 2008), I drilled down to Distribution$ControlImage_Name and created $OEM$$$System32 folder structure. I then placed the additional DLLs in the System32 folder and deployed the image. It worked great! Would this be considered a proper way to deploy DLLs by Microsoft's standards? -thanksAnonymous
June 19, 2008
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.Anonymous
June 26, 2008
The comment has been removedAnonymous
July 01, 2008
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. Thanks, DanAnonymous
November 11, 2008
For: ERROR 3 (0x00000003) Getting File System Type of Source Need to make sure your script maps those network drives in the script. The scheduled task environment does not assume the user running the task has logged in.Anonymous
November 20, 2008
The robocoy.doc file coming with the Server 2003 resource kit contains the following (complete?) list of return codes for robocopy version XP010: The return code from Robocopy is a bit map, defined as follows: Hex Bit Value Decimal Value Meaning If Set 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. 0x08 8 Some files or directories could not be copied (copy errors occurred and the retry limit was exceeded). Check these errors further. 0x04 4 Some Mismatched files or directories were detected. Examine the output log. Housekeeping is probably necessary. 0x02 2 Some Extra files or directories were detected. Examine the output log. Some housekeeping may be needed. 0x01 1 One or more files were copied successfully (that is, new files have arrived). 0x00 0 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.Anonymous
December 14, 2008
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. I think Helge was confused and submitted the information that is included at the beginning of this page. Vegas, here are a few more that I have come across: 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. ERROR 58 (0x0000003A) Copying NTFS Security to Destination File: The specified server cannot perform the requested operation ERROR 1359 (0x0000054F) Scanning Source Directory: An internal error occurred. ERROR 1359 (0x0000054F) Copying File: An internal error occurred. Hope it helps and isn't too late - if perchance you come across a true list, please post it here :)Anonymous
February 02, 2009
Hi, I need help on following error message. Anu clues ? 009/02/01 23:02:09 ERROR 2 (0x00000002) Time-Stamping Destination File X:file6568 The system cannot find the file specified. Thanks AnupAnonymous
April 30, 2009
Hi Daniel, could you please help us on solving the below problem. 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. 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. So we need to stop the process only if the error code is not = to 1 and how to trap it. Thanks.Anonymous
August 16, 2009
What is the variable name for the return codes In Xcopy it is errorlevel Thanks Frank C ( I don't have a URL)Anonymous
February 06, 2010
12Anonymous
March 09, 2010
Looks like these are Win32 Error codes: see http://infosys.beckhoff.com/index.php?content=../content/1031/tcdiagnostics/html/tcdiagnostics_win32_errorcodes.htm&id=Anonymous
September 07, 2014
I have just spent most of an entire day experimenting with RoboCopy, ending, in great frustration, having confirmed that the documentation of exit code 0x00 is WRONG. I can prove, by way of RoboCopy's own logs, that successfully copying of a new file returns exit code ZERO, not one, as claimed in the documentation here and at http://support.microsoft.com/kb/954404.