Help Center

Follow

Using Robocopy with PDQ Deploy

Robocopy is a fantastic copy utility that I have used for years. There is one small gotcha when using Robocopy, however. The "gotcha" has to do with Exit Codes (AKA Error Codes, AKA Return Codes).

Exit Code 0 is, for the most part, the code that most processes, applications and installers use when NO errors were encountered. A non-zero exit code generally means that there was a problem encountered somewhere.

For Robocopy, Exit Code 0 means that there were NO errors and that NO files were copied. (this way you know that if there were any new files to be copied that they would have been but the source and target directories are already synchronized). 

Exit Code 1 means that one or more files copied SUCCESSFULLY! This means that you need to define the exit code 1 to your list of Successful Return Codes.

RobocopyReturnCode.png

 

Here is a site containing the Exit Codes for Robocopy.

Keep in mind that Error 16 usually means that there is a permissions error on either the Target or Source directories. Make sure that the credentials you are using with PDQ Deploy have the appropriate rights on both the target computer (must have administrative rights) and the source directory (must be able to see, access and copy from source). You can see the credentials you are using in the Deploy Now window. In the example below, the use account GConstanza in the Vandalay domain must be an Administrator of the all the target machines AND must be able to see and copy files from the \\Scranton\e$\deploy\OpenZone directory. (source directory referenced in image above)

1.4DeployCredentials.png

Was this article helpful?
1 out of 1 found this helpful
Have more questions? Submit a request

6 Comments

  • 0

    You can use this information in a batch file to report the most serious anomalies, as follows:

     

    if errorlevel 16 echo ***FATAL ERROR*** & goto end

    if errorlevel 8 echo **FAILED COPIES** & goto end

    if errorlevel 4 echo *MISMATCHES* & goto end

    if errorlevel 2 echo EXTRA FILES & goto end

    if errorlevel 1 echo Copy successful & goto end

    if errorlevel 0 echo --no change-- & goto end

    :end

     

    Alternatively, full details of the return code could be reported as follows:

     

    if errorlevel 16 echo ***FATAL ERROR*** & goto end

    if errorlevel 15 echo FAIL MISM XTRA COPY & goto end

    if errorlevel 14 echo FAIL MISM XTRA & goto end

    if errorlevel 13 echo FAIL MISM COPY & goto end

    if errorlevel 12 echo FAIL MISM & goto end

    if errorlevel 11 echo FAIL XTRA COPY & goto end

    if errorlevel 10 echo FAIL XTRA & goto end

    if errorlevel 9 echo FAIL COPY & goto end

    if errorlevel 8 echo FAIL & goto end

    if errorlevel 7 echo MISM XTRA COPY & goto end

    if errorlevel 6 echo MISM XTRA & goto end

    if errorlevel 5 echo MISM COPY & goto end

    if errorlevel 4 echo MISM & goto end

    if errorlevel 3 echo XTRA COPY & goto end

    if errorlevel 2 echo XTRA & goto end

    if errorlevel 1 echo COPY & goto end

    if errorlevel 0 echo --no change-- & goto end

    :end

  • 0

    Thanks for adding those, Dany. I had to come back to this post to reference these return codes. You're awesome.

  • 0

    Hi Shane,
    I am trying to use robocopy to copy a directory to students computers either to c:\program files but is not happening.
    my comand : - robocopy \uhsstore\stuffs\admin arsenal\notpad++ c:\program files\notepad++ runs OK reports succesfull but does not show as such nor does it land on target machines?
    please help

    thanks
    Larry

  • 0

    Larry, you may want to try xcopy, it tends to be a bit more robust when run in the background.  Or, you could try redirecting the output from robocopy to a text file to see if it's giving a warning about why it's not doing aything:

    robocopy \uhsstore\stuffs\admin arsenal\notpad++ c:\program files\notepad++ >> c:\copy.log 2>&1

    (The log file will be created on the target computer, not your computer.)

  • 0

    what os are you running on pcs deploying to?

    xp does not have robocopy.

    windows 7 8 no problem.

  • 0

    mkdir c:\"program files"\notepad++

    xcopy \uhsstore\stuffs\admin arsenal\notpad++\*.* c:\"program files"\notepad++ /e /y

    will this help?

Article is closed for comments.