If you’re trying to change permissions on a folder, including files and subfolders, and you’re getting an error message from Windows saying that it failed to enumerate the objects in the container because access is denied, the following may help you:
- Start an elevated command prompt window (hit “CTRL+Q” > type “cmd” in the field > right click and select “Run as the administrator” on “Command Prompt”)
- Navigate to the folder that contains the one you wish to change permissions on (in the command prompt, you can use “cd” followed by the name of the folder you wish to access in order to enter that folder).
- Once there, type the following (replace the folderName with the actual name of the folder):
takeown /f folderName /r /d y
This command will take ownership of the entire folder and its contents. You can now return to your File Explorer and right-click to set the permissions as you wish.
What do the parameters do?
/f: defines the file or folder name
/r: defines a recursive function (means that all folders and files contained in that folder will also be affected)
/d y: defines a default answer (in this case y=yes), in case the user does not have “list contents”. This means that the user will take ownership even in that case.
We actually are also facing an “Access Denied” error when working with Sitefinity projects that we download from TFS. The usual yellow page displays this error: “UnauthorizedAccessException: Access to the path ‘x:’longpath\App_Data\Sitefinity\Configuration\someDotConfigFile.config’ is denied”. The same “takeown” command helps resolve this issue as well. After running the command, start the IIS manager, right click on the site in the Sites list on the left hand side column, select “Edit Permissions” and then uncheck the option “Read-only”. Hit apply, and the Access Denied error should go away.