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!
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
Will this work for adding .dll files to C:\Windows\System32 for Vista?
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!
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$\Control\Image_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?
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.
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.
Thanks again for the information. I haven't had great success using robocopy lately. How would my command line look for moving .dlls from the deployment server to the target PC system32 folder for Vista?
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:\windows\system32" to copy your files.
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.
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:
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:
0x00 No errors occurred, and no copying was done. The source and destination directory trees are completely synchronized.
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:
ERROR 2 (0x00000002) The system cannot find the file specified.
ERROR 3 (0x00000003) The system cannot find the path specified.
ERROR 5 (0x00000005) Access is denied.
ERROR 6 (0x00000006) The handle is invalid.
ERROR 32 (0x00000020) The process cannot access the file because it is being used by another process.
ERROR 53 (0x00000035) The network path was not found.
ERROR 64 (0x00000040) The specified network name is no longer available.
ERROR 112 (0x00000070) There is not enough space on the disk.
ERROR 121 (0x00000079) The semaphore timeout period has expired.
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.
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.
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.
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 :)
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.
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.