locked
ROBOCOPY: ERROR 32 (0x00000020) Accessing Destination Directory. The process cannot access the file because it is being used by another process. RRS feed

  • Question

  • Thanks in advance for your help. 

    I am using ROBOCOPY to copy some files from on drive to another on the same computer. Every once in awhile, I get an error. And instead of retrying 999 times as it should, it retries once and fails. I have a couple questions:

    1. Why would this error be happening in the first place?

    2. Why isn't ROBOCOPY retrying the 999 times as defined?

    Commands are below:

    >> mkdir C:\Users\tempuser\AppData\Local\temp\test1

    >> robocopy /R:999 /W:5 /NP /E /XO /NFL /NDL E:\test1 C:\Users\tempuser\AppData\Local\temp\test1 test* 

    -------------------------------------------------------------------------------
       ROBOCOPY     ::     Robust File Copy for Windows                              
    -------------------------------------------------------------------------------

      Started : Monday, March 25, 2013 4:20:51 AM
       Source : E:\test1 
         Dest  : C:\Users\tempuser\AppData\Local\temp\test1

        Files : test*

      Options : /NDL /NFL /S /E /DCOPY:DA /COPY:DAT /NP /XO /R:999 /W:5 

    ------------------------------------------------------------------------------

    2013/03/25 04:20:51 ERROR 32 (0x00000020) Accessing Destination Directory C:\Users\tempuser\AppData\Local\temp\test1
    The process cannot access the file because it is being used by another process.

    Waiting 5 seconds... Retrying...

    ------------------------------------------------------------------------------

                   Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         1         0         0         0         1         0
       Files :         0         0         0         0         0         0
       Bytes :         0         0         0         0         0         0
       Times :   0:00:05   0:00:00                       0:00:05   0:00:00
       Ended : Monday, March 25, 2013 4:20:56 AM

       
    Monday, March 25, 2013 3:50 PM

All replies

  • Hi,

    Based on your description, I’m afraid that it is not the correct forum for this issue, since this forum is to discuss VS debugger/profiler tool issue.

    I am moving your question to the moderator forum ("Where is the forum for..?"). The owner of the forum will direct you to a right forum.

    Like this document, it seems that it is related to the Windows Server, maybe you could post this issue to the windows Server forum: http://social.technet.microsoft.com/Forums/en-US/category/windowsserver. Anyway, I move it to the moderator forum. Thanks for your understanding.

    Best Regards,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.


    Tuesday, March 26, 2013 6:39 AM
  • sorry but thisis also not the right forum for RoboCopy.  Thisis a scriping foumand RoboCopy is a utility.

    Someone will move this thread but start by looking at this line of your output.

                Total    Copied   Skipped  Mismatch    FAILED    Extras
        Dirs :         1         0         0         0         1         0

    Notice that you DIR access failed because of a mismatch.


    ¯\_(ツ)_/¯

    Wednesday, March 27, 2013 3:54 AM
  • From the error, a file is locked when trying to copy with robocopy. You should try to find it with tools like handle.exe, or check MMC - FIle Share - Open files. Also test to add /ZB to see if it will work.

    TechNet Subscriber Support in forum |If you have any feedback on our support, please contact tnmff@microsoft.com.

    Monday, April 1, 2013 6:14 AM
  • It is amazing that this post is everywhere on the Internet and everyone seems to answer by pointing out the obvious.

    The OP knows that the file is open and locked.  The question is "WHY"?  Why does RoboCopy seem to abort after 1 retry when the command line specifies 999 reties?

    I say that it is quitting after 999 reties because they are not set up with a delay.

    Some file will be perpetually locked.  You will never be able to copy these.  Track down what process or service is using the file.


    ¯\_(ツ)_/¯

    Monday, April 1, 2013 6:41 AM
  • Hi,

    OP added /W:5 so it seems that the delay is already added.

    As I mentioned in my reply, you could try to run a tool like "handle.exe" or check Open files to see if they could help show the exact process which locked the file.

    Meanwhile, add /ZB in the command to see if it will still run the command once instead of 999. However if it is a file locking issue, it may not work to retry the command before file get unlocked.


    TechNet Subscriber Support in forum |If you have any feedback on our support, please contact tnmff@microsoft.com.

    Friday, April 5, 2013 6:40 AM
  • Please note that the error message is about a *directory* being used by another process, not a *file*.

    So the question is: why does Robocopy consider a *directory* exclusively locked here?

    Wednesday, October 25, 2017 1:17 AM
  • The error clearly states "The process cannot access the file because it is being used by another process."

    \_(ツ)_/


    • Edited by jrv Wednesday, October 25, 2017 1:34 AM
    Wednesday, October 25, 2017 1:34 AM