Take ownership of a file or folder with takeown and icacls

Two-step command sequence that makes you the owner of a locked file tree and grants yourself full control — the standard fix for 'Access is denied' on old profiles and OS reinstall leftovers.

WindowsFilessystemsecurityHigh risk
Run `takeown /F "<path>" /R /D Y` to claim ownership, then `icacls "<path>" /grant "%USERNAME%:F" /T` to grant yourself full control of the whole tree.

01Command

Command
$ takeown /F "C:\Users\OldProfile\Documents" /R /D Y && icacls "C:\Users\OldProfile\Documents" /grant "%USERNAME%:F" /T

02What it does

Access-denied usually means the ACL points at a deleted SID (old profile, rebuilt system); ownership is the only right that overrides the ACL itself, so takeown must run first — as an administrator it can always claim ownership. /R recurses into subfolders and /D Y auto-answers the 'are you sure' prompt (note /D must come last). icacls then grants your account Full control (:F) and /T applies it to every child object. Before changing anything, record the current owner with `icacls "<path>"` so you can restore it; the newer `icacls /setowner` can hand ownership back.

03Risk

RiskHigh risk
RequirementsRun as administrator; ownership changes cannot be reversed automatically unless you note the previous owner first.
!Warning: Changing ownership on system folders like Windows or Program Files can break the OS and Windows Update — only do this on user data directories you control.

04Undo

✓No undo needed — this command does not change persistent state.

05Sources

  • takeown | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents takeown /F with /R for recursive ownership and /D Y to answer prompts, making the administrator the file owner.
  • icacls | Microsoft Learn
    Microsoft · vendor-doc · 2026-09-17
    Evidence: Microsoft documents icacls /grant with the :F permission and /T for applying the ACE recursively to all files and subfolders.

Last verified: 2026-09-17 · Category: Files & Folders

06Related solutions