Take ownership of a file (Windows 2003/7/2008).
Syntax
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.
After changing the owner for a file/folder, you can then assign full permissions to the files and subsequently read or delete them.
“As every cat owner knows, nobody owns a cat” ~ Ellen Perry Berkeley
Related:
CACLS - Change file permissions.
iCACLS - Change file and folder permissions.
ATTRIB - Display or change file attributes.