原文位址:[url]http://blogs.technet.com/deploymentguys/archive/2008/06/16/robocopy-exit-codes.aspx[/url]
Robocopy exit codes
是以Destination中的所有txt檔案都是非隻讀的。
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.
robocopy是一個非常棒的工具,我常常在部署工程中用他來移動檔案。我想他最有用的一個特性就是/MIR參數。它讓我們可以僅僅更新一個檔案夾裡遺失或改變的檔案。
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.
在TS中,robocopy有一個問題——它并不是總是傳回錯誤代碼0,甚者copy已經成功。這就帶來一個麻煩:如下圖所示,我将robocopy指令行直接加入TS中,使用了預設的成功代碼,在大多數案例中,他正常工作,但在robocopy裡,你會發現部署失敗,顯示robocopy并不傳回一個成功代碼,盡管有時copy是成功的。
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.
These can be combined, giving a few extra exit codes:
0×03 3 (2+1) Some files were copied. Additional files were present. No failure was encountered.
0×05 5 (4+1) Some files were copied. Some files were mismatched. No failure was encountered.
0×06 6 (4+2) Additional files and mismatched files exist. No files were copied and no failures were encountered.
This means that the files already exist in the destination directory
0×07 7 (4+1+2) Files were copied, a file mismatch was present, and additional files were present.
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.
我強烈建議你使用/log參數,robocopy會建立一個完整的日志檔案,這在排錯時很有用
This post was contributed by Daniel Oxley a consultant with Microsoft Services Spain
Published Monday, June 16, 2008 8:51 AM by DeploymentGuys