4

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.

9
  • If you open a command prompt window (as admin) and do icacls on the folder, what do you get?
    – soandos
    Apr 28, 2015 at 21:24
  • Nothing: "Access is denied".
    – Eric Dand
    Apr 28, 2015 at 21:34
  • Even when running as admin?
    – soandos
    Apr 28, 2015 at 21:34
  • Yes sir. When I reboot the machine, the folder often disappears or becomes under my control again, but the problem reoccurs fairly often, sometimes before the build can complete successfully even once.
    – Eric Dand
    Apr 28, 2015 at 21:50
  • Maybe run chkdsk on the drive when it is denied? It might not be there at all
    – soandos
    Apr 28, 2015 at 21:50

2 Answers 2

4

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.

2

A few possibilities for resolving locked files:

  1. The System or an application is locking it; use a tool such as CrystalRich LockHunter to find out what, and if you wish, unlock it. Sometimes a computer needs to be restarted in order to relinquish all locks, particularly if the object is used by a web site.

  2. Setting permissions on a folder is a bit tricky; there are multiple steps. See How to Grant Full Permissions....


Some other possibilities:

  1. Some "folders" are actually symbolic links, such as C:\ProgramData\Application Data; these are inaccessible. However, since you could access the folder before, that seems unlikely.

  2. MS has lately started using a TrustedInstaller account, so even Admin cannot touch some files and folders (though from your description that is probably not the cause oif the issue).

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .