|

How To Use The Takeown Command In Windows (2027)

Takeown makes you the owner of a file or folder, which is often the first step when Windows says you were denied access.

The basic form is takeown /f , and adding /r covers every file inside a folder.

This guide follows Microsoft’s takeown and icacls references, so each switch below is documented.

Table of Contents

Takeown quick answers

I want toType this
Take ownership of a filetakeown /f lostfile
Give ownership to the Administrators grouptakeown /f /a
Take ownership of a folder and everything in ittakeown /f /r
Answer the folder prompt automaticallytakeown /f /r /d Y
Then grant yourself full permissionsicacls /grant :F

Replace the placeholders with your own path, and put quotes around any path that contains a space.

What takeown does

Microsoft describes takeown as a command that lets an administrator recover access to a file that was previously denied, by making the administrator the owner.

It lists Windows 11 and Windows 10 as supported versions.

Owning a file is not the same as having permission to change it, which is why the permission step further down matters.

Be careful with ownership changes

Take ownership only of files and folders that belong to you or that you have a clear reason to change, and keep a backup of anything important first.

Microsoft says that takeown with /d Y replaces a directory’s permissions with full control for you only.

For checking damaged system files without changing ownership, see the SFC and DISM guide.

Open Command Prompt as administrator

  1. Press the Windows key and type cmd.
  2. Right-click Command Prompt and choose Run as administrator.
  3. Type your takeown command and press Enter.

The steps for an elevated window are in how to open Terminal as administrator.

The takeown syntax

Microsoft gives the syntax as takeown [/s [/u [\] [/p []]]] /f [/a] [/r [/d {Y|N}]].

The only required part for a local file is /f followed by the file or folder name.

Takeown switches at a glance

SwitchWhat it does
/f Sets the file or directory name pattern, and you can use the * wildcard.
/aGives ownership to the Administrators group instead of the current user.
/rWorks on all files in the directory and its subdirectories.
/d {Y|N}Answers the prompt shown when you lack List Folder and Read permissions, and it must be used with /r.
/s Names a remote computer, with no backslashes, and the default is the local computer.
/u and /pRun the command with another user account and its password.

Take ownership of one file

  1. Open an elevated Command Prompt.
  2. Run takeown /f "C:\Path\to\file.txt" with your own path.
  3. Watch for an error message, and if one appears, check the path and that the window is elevated.

Microsoft’s own example is takeown /f lostfile.

By default, ownership goes to the user who is currently logged on.

Give ownership to the Administrators group

Add /a when you want the Administrators group to own the item instead of your account.

Microsoft says that without this option, ownership goes to the user currently logged on to the computer.

Take ownership of a folder and its contents

Use /r to run the operation on every file in the folder and its subfolders.

A folder example is takeown /f "D:\Old Files" /r, with the path as a placeholder.

If you lack List Folder and Read permission on a subfolder, takeown asks what to do unless you add /d.

Choose Y or N for the /d prompt

ValueWhat happens
YTakes ownership of the directory, and its permissions are replaced with permission granting you full control only.
NSkips the directory.

Microsoft requires the /d option to be used together with /r.

Wildcard limits

Microsoft says the * wildcard works in the /f pattern.

Mixed patterns that use both ? and * are not supported by takeown.

Grant yourself full permissions afterward

Microsoft notes that after takeown, you might have to use Windows Explorer to give yourself full permissions before you can delete the files and directories.

The icacls command does the same from the command line.

icacls optionWhat it does
/grant :FGrants full access, and without :r the permission is added to existing explicit permissions.
/setowner Changes the owner of all matching files to the user.
/TApplies the operation to files in the folder and its subfolders.
/CContinues even if file errors occur.
/resetReplaces ACLs with the default inherited ACLs.

Permission letters you can use with icacls

LetterAccess it gives
FFull access.
MModify access.
RXRead and execute access.
RRead-only access.
WWrite-only access.
DDelete access.
NNo access.

Pick the smallest permission that does the job, such as M to change files or RX to open them.

Microsoft says SIDs can be friendly names or numerical values prefixed with an asterisk.

Save permissions before you change them

Run icacls /save permissions.txt /T to store the current permissions in a file.

Microsoft documents /restore as the option that applies the stored permissions to the files in a directory.

Microsoft’s example saves the permissions for everything under a folder with /t and restores them with icacls /restore .

Use takeown on another computer

The /s switch names a remote computer by name or IP address, without backslashes.

The /u switch runs the command under another account, and the default is system permissions.

Most home users never need these switches, since the default is the local computer.

Mistakes that stop takeown from working

  • Running it in a window that is not elevated.
  • Using a mixed ? and * pattern, which Microsoft says is not supported.
  • Using /d without /r, since Microsoft requires them together.
  • Expecting ownership alone to let you delete the file, when you may still need to grant full permissions.

Take ownership and get access step by step

  1. Open an elevated Command Prompt.
  2. Run takeown /f , adding /r for a folder.
  3. Run icacls /grant :F, adding /T for a folder.
  4. Try the action that was denied before, such as opening or deleting the item.

Microsoft’s icacls page also offers /save to store permissions first, and /restore to apply them again.

Related guides

For the Explorer route to the same problem, see how to fix folder access denied in Windows 11.

For copying files you now own, see the Robocopy guide.

Official sources

The switches and example come from Microsoft’s takeown reference.

The permission options come from Microsoft’s icacls reference.

Leave a Reply

Your email address will not be published. Required fields are marked *