Windows – Administrator denied access to folder, impossible to see/change owner

file-permissionspermissionspowershellwindows 8windows 8.1

I have a folder which was generated by MSBuild, app.publish. Often, my build script fails to delete it, complaining that it does not have the necessary permissions. Today I tested this outside of the build script, and found I could not even open it.

If I try to open it, I get this message:

Access denied error

"Location is not available. Access is denied."

So I tried to change the permissions, but could not even see who the owner was, even as an administrator:

Security Settings for Folder

So then I thought it might be a problem with Explorer, so I tried from PowerShell. Unfortunately, access is also denied there. I tried using Get-ACE -Path app.publish, but that also refused to work: "Access is denied." I also tried icacls app.publish /grant ijhbvhbv:f, but that too failed and said "Access is denied." I tried both of these commands both as my regular user, and as the administrator.

Finally, I tried to delete the parent directory, but was told I had to "provide adminstrator permission to delete this folder". When I did, I got a curious error: "You require permission from FWEE-ERIC-WIN8\ijhbvhbv to make changes to this folder". "FWEE-ERIC-WIN8\ijhbvhbv" is my own account. So it seems that I am indeed the owner of the folder, but only when I try to interact with it as the administrator.

Other questions about this on SU talk about UAC as a potential source of the problem, but the problem is the same no matter what UAC is set to.

Best Answer

After spending way too long on a similar problem I figured it out.

This happen to folders that are:

  • Do not have a valid owner
  • Are lock because some application still uses them.
  • Have been otherwise deleted.

The folder is in a "zombie" state as it was deleted, but is still in use by some process. You need to find the process that uses it and close it, or, if you have no idea which it is, reboot the machine.

You'll be left with the folder gone. If a whole subtree was deletd, but only one folder in it was used, you may need to come back and cleanup the subtree manually. This should work with admin rights.

Related Question