Taking Ownership of a Reluctant Directory in Windows 10

I have couple of times found that I cannot access a certain folder, and when I try to take ownership of that folder to change permissions, I get “access denied” error. It doesn’t matter if I try using File Explorer or the takeown command. One way to solve this is to boot in safe mode, start a command prompt and use takeown /f folder-name /r /a which will give the administrators group recursive ownership of the folder. Then exit the command prompt and start Windows as usual.

Now, you can for example:

  • replace ACLs with default inherited ACLs for all matching files:
    icacls "folder-name\*" /t /reset (t means recurse to all subfolders)
  • remove grants for a specific user:
    icacls "folder-name" /remove user-name /t
  • add full access to administrators:
    icacls "folder-name" /grant:r "administrators:(OI)(CI)F" (:r means replace, not just add, (OI) means inherit to all objects (files), (CI) means inherit to containers (sub-folders))