天天看点

Robocopy exit codes

原文地址:[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