Steps
- Click Start, type
cmd, then right-click Command Prompt and choose Run as Administrator. - Take ownership of the file:
takeown /F "C:\PathToFile.ext"
- Grant your administrators group full control:
icacls "C:\PathToFile.ext" /grant administrators:FAfter both commands complete successfully, you’ll have full ownership and permissions over the file and can delete, move, or edit it as needed. For a whole folder rather than a single file, add
/R to both commands to apply the change recursively to every file and subfolder underneath it.
Why This Happens in the First Place
Ownership and permissions are two separate things in Windows — being a member of the Administrators group grants you broad rights, but it doesn’t automatically make you the owner of every file on the system. Files created by the System account (Windows Update components, some driver files), by TrustedInstaller (core OS files under Windows Resource Protection), or by another user profile entirely all keep their original owner until something explicitly changes it — which is exactly whattakeown does.
The PowerShell Equivalent
If you’d rather do this from PowerShell than Command Prompt, the same two-step process looks like this:$acl = Get-Acl "C:\PathToFile.ext" $acl.SetOwner([System.Security.Principal.NTAccount]"$env:USERDOMAIN$env:USERNAME") Set-Acl "C:\PathToFile.ext" $acl icacls "C:\PathToFile.ext" /grant administrators:FIn practice
takeown/icacls remains the quicker route for a one-off fix, but the PowerShell version is worth knowing if you’re already scripting a wider permissions-remediation task.
If It Still Won’t Delete
Taking ownership fixes the vast majority of “administrator denied” delete errors, but if the file is still locked afterwards, check whether another process has it open (Resource Monitor’s CPU tab has a “Search Handles” box for exactly this), or whether it’s a system-protected file guarded separately by Windows Resource Protection — in which case ownership alone won’t be enough and modifying it isn’t recommended unless you know exactly why you need to.
Gear We Recommend
A few general tech accessories worth having alongside this.
Browse our General Tech Accessories picks on AmazonAs an Amazon Associate, TechyGeeksHome earns from qualifying purchases.
Discover more from TechyGeeksHome
Subscribe to get the latest posts sent to your email.