Enables an administrator to recover access to a file that previously was denied, by making the administrator the owner of the file. This command is typically used on batch files.
Syntax
takeown [/s <computer> [/u [<domain>\]<username> [/p [<password>]]]] /f <filename> [/a] [/r [/d {Y|N}]]
Parameters
| Parameter | Description |
|---|---|
/s <computer> |
Specifies the name or IP address of a remote computer (do not use backslashes). The default value is the local computer. This parameter applies to all of the files and folders specified in the command. |
/u [<domain>\]<username> |
Runs the script with the permissions of the specified user account. The default value is system permissions. |
/p [<[password>] |
Specifies the password of the user account that is specified in the /u parameter. |
/f <filename> |
Specifies the file name or directory name pattern. You can use the wildcard character * when specifying the pattern. You can also use the syntax <sharename>\<filename>. |
| /a | Gives ownership to the Administrators group instead of the current user. If you don't specify this option, file ownership is given to the user who is currently logged on to the computer. |
| /r | Performs a recursive operation on all files in the specified directory and subdirectories. |
| /d `{Y | N}` |
| /? | Displays help at the command prompt. |
Remarks
-
Mixed patterns using (? and *) aren't supported by takeown command.
-
After deleting the lock with takeown, you might have to use Windows Explorer to give yourself full permissions to the files and directories before you can delete them.
Examples
To take ownership of a file named Lostfile, type:
takeown /f lostfile
Related links
Source: Microsoft Learn / Windows Server documentation by Microsoft and contributors (upstream author metadata: robinharwood). Documentation licensed CC BY 4.0. Code samples are covered by the MIT License. Converted from Markdown, with links normalized and embedded media omitted.
