Take ownership of a file or folder.

      TAKEOWN [/s Computer [/u [Domain\]UserName [/p [Password]]]]
         /f FileName [/a] [/r [/d {Y|N}]]
Key /s Computer The name or IP address of a remote computer (do not use backslashes). default = local computer. This parameter applies to all of the files and folders specified in the command. /u [Domain\]UserName Run the script with the permissions of the specified user account. default = system permissions. /p [Password] The password of the user account that is specified in the /u parameter. /f FileName The file name, UNC path or directory name pattern. Accepts the wildcard character * /a Give ownership to the Administrators group instead of the current user. /r Perform a recursive operation on all files in the specified directory and subdirectories. /d {Y | N} Suppress the confirmation prompt that is displayed when the current user does not have the "List Folder" permission on a specified directory, and instead use a default value: Y: Take ownership of the directory. N: Skip the directory. Note that you must use this option in conjunction with the /r option.

If the /a parameter is not specified, file ownership is given to the user who is currently logged on to the computer.

Mixed patterns using (? and *) are not supported by the takeown command.

If the file/folder is currently open (locked) it may not be possible to change the ownership or permissions without first closing the file locks. This can be done in Computer Management ➞ Shared Folders ➞ Open files.

After changing the owner for a file/folder, you can then assign full permissions to the files and subsequently read or delete them.


Transfer ownership of the file D:\demo\sample.xlsx to the Administrators group:

C:\> takeown.exe /f D:\demo\sample.xlsx /a

“As every cat owner knows, nobody owns a cat” ~ Ellen Perry Berkeley

Related commands

CACLS - Change file permissions.
iCACLS - Change file and folder permissions.
ATTRIB - Display or change file attributes.

Copyright © 1999-2024 SS64.com
Some rights reserved