robocopy bug with /b switch RRS feed

  • Question

  • Robocopy without /b is able to copy files which are currently open (e.g. a Word document open in Word).

    Robocopy with /b is not able to copy these same files.

    Steps to reproduce:


    • your user account is an administrator (in a domain, you are in Domain Admins).
    • your user account is in the "Backup Operators" group.
    • you have logged off and back on since adding yourself to Backup Operators.
    1. Create a folder called 'source'.
    2. In 'source', create a Word document called 'file.docx'.
    3. Open 'file.docx' in Word.
    4. Run Powershell as administrator and cd to the directory in which you created 'source'.
    5. robocopy /mir source\ dest_without_b\
    6. robocopy /mir source\ dest_with_b\ /b

    Expected result:

    Steps 5 and 6 both complete without error, and target folders "dest_without_b" and "dest_with_b" now contain "file.docx" and "~$file.docx" (Word's "I have this file open" file).

    Actual result:

    Step 5 succeeds, but step 6 fails with this error:

    2014/08/27 10:36:58 ERROR 32 (0x00000020) Copying File G:\scratch\source\file.docx
    The process cannot access the file because it is being used by another process.
    Waiting 30 seconds...


    • This bug is present in at least Windows 8, 8.1, 7, and Server 2008 R2.
    • This bug happens regardless of whether source\file.docx is a local file or on a network share, and regardless of whether file.docx is open on the local machine or the remote machine.
    • This means that when backing up a workstation where someone is currently logged on, I need to choose between getting files which the user has open, and getting files which my user account does not have permission to. I can run robocopy twice, once with /b and once without, and hope that I get everything -- but I will not get files which are both in use and not readable to my user account.
    • There are at least two different kinds of "file open" in Windows: Microsoft Word's "I have this file open but I'll still let you copy it" mode, and the "You are never copying this file while the computer is running, unless you use Volume Shadow Copy" mode used by the Windows registry. Robocopy cannot copy files in the latter case, with or without /b (but it would be really nice if it could).

    Finally, I'm new to reporting bugs in Windows / Microsoft products. Is there a public bugzilla / bug tracker or something?

    Wednesday, August 27, 2014 5:52 PM

All replies

  • Hi,

    Please adjust the order of the step 5 and step 6.

    Or please run step 5 and step 6 in different time. Run the step 5 completely finishing, after a while, then run the step 6 for test.

    Karen Hu
    TechNet Community Support

    Thursday, August 28, 2014 8:42 AM
  • Step 5 has completely finished by the time I start step 6. There are only two very small files in 'source', so these complete very quickly.

    Anyway, just did them like this:

    robocopy /mir source\ dest_without_b\

    verify that robocopy.exe has completely finished by verifying that it is not in task manager.

    wait 2 minutes.

    robocopy /mir source\ dest_with_b\ /b

    Same result as above.

    The point of the exercise though is that it's Microsoft Word holding the file open -- and one robocopy command line is able to copy it even with the file open in Word, while the other command line is not.

    Thursday, August 28, 2014 7:20 PM
  • Hi,

    Robocopy doesnt copy open files. The defaults allow 1 million retries, at 30-second intervals, allowing copy
    operations to complete when an open file is closed, even if hours or days have passed since the command was first launched.

    Thus, please run robocopy /mir source\ dest_with_b\ /b after you restart the computer to check the result.

    Karen Hu
    TechNet Community Support

    Monday, September 1, 2014 7:04 AM
  • Hi,

    Robocopy doesnt copy open files.

    I don't understand -- my example shows that robocopy clearly can and does copy open files (sometimes). To see this, stop after completing step 5.

    Are you saying that the robocopy spec says that robocopy makes no *guarantees* about being able to do this, and therefore this isn't a bug because "ERROR 32" is valid behaviour for an open file according to the spec?

    Where can I find specs for commands like robocopy?

    Tuesday, September 2, 2014 3:38 PM
  • Robocopy does not copy open files, it can copy ones that do not have handles on them like PDF files, even if they are open, it will be able to copy them as Adobe does not place handle locks.

    We had the same issue and needed top copy open files, we ended up using GSCopyPro which is very much like robocopy but can do a few more good stuff like copy open files, send an email, and provides a nice rich gui so we do not have to write any commands if we do not want to.  we are using version 8.1

    good luck

    Thursday, October 9, 2014 7:23 PM
  • Try using ShadowSpawn (an open source project) with robocopy.  See the ShadowSpawn GitHub project page.

    Sorry I can't place an URL in this reply beause TechNet says it has verified my account.

    Thursday, June 27, 2019 3:54 PM