Getting Access Denied Error 5 When Using Robocopy

Problem:

Getting access denied error 5 when using Robocopy

Solution:

(h/t Al, see KB979808 http://support.microsoft.com/kb/979808)
(Quick hot fix download: 406633_intl_x64_zip)

Consider the following scenario:

  • You add a user account to the domain Backup Operators group or to the local Backup Operators group.
  • You use this account to log on to a computer that is running Windows 7 or Windows Server 2008 R2.
  • You use the Robocopy command together with the /B option to copy some files that you do not have access permissions or ownership.

In this scenario, these files are copied successfully. However, their security configuration information such as an access control list (ACL) is not copied. Instead, these files inherit their ACL from the destination folder.

Additionally, the Robocopy.exe utility returns one of the following error messages:

  • ERROR 5 (0x00000005) Copying NTFS Security to Destination Directory <directory name> Access is denied
  • ERROR 5 (0x00000005) Copying NTFS Security to Destination File<directory name> Access is denied

Note When a member of the Backup Operators group runs the Robocopy.exe utility together with the /B option to copy a file, everything should be copied. The member should have access to the file security configuration information even if the member does not have permissions to the file or ownership of the file.

Collapse imageCAUSE

This issue occurs because the Robocopy.exe utility does not open these files by using the “backup intent” flag when the /B option is used. This behavior prevents access to the security configuration information for a user who has the “Back up files and directories” (SE_BACKUP_PRIVILEGE) privilege.Note If a file is opened by using the “backup intent” flag, certain access rights are checked, and then the user who opened the file is granted the appropriate access to the file.

Collapse imageRESOLUTION

Hotfix information

A supported hotfix is available from Microsoft. However, this hotfix is intended to correct only the problem that is described in this article. Apply this hotfix only to systems that are experiencing the problem described in this article. This hotfix might receive additional testing. Therefore, if you are not severely affected by this problem, we recommend that you wait for the next software update that contains this hotfix.

If the hotfix is available for download, there is a “Hotfix download available” section at the top of this Knowledge Base article. If this section does not appear, contact Microsoft Customer Service and Support to obtain the hotfix.

Note If additional issues occur or if any troubleshooting is required, you might have to create a separate service request. The usual support costs will apply to additional support questions and issues that do not qualify for this specific hotfix. For a complete list of Microsoft Customer Service and Support telephone numbers or to create a separate service request, visit the following Microsoft Web site:

Note The “Hotfix download available” form displays the languages for which the hotfix is available. If you do not see your language, it is because a hotfix is not available for that language.

Prerequisites

To apply this hotfix, your computer must be running Windows Server 2008 R2 or Windows 7.

Restart requirement

You do not have to restart the computer after you apply this hotfix.