Tuesday, 5 May 2020

takeown

https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/takeown

takeown

Enables an administrator to recover access to a file that previously was denied, by making the administrator the owner of the file.

Syntax

takeown [/s <Computer> [/u [<Domain>\]<User name> [/p [<Password>]]]] /f <File name> [/a] [/r [/d {Y|N}]]

Parameters

Table 1
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>] 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 <File name> 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.
/r Performs a recursive operation on all files in the specified directory and subdirectories.
/d {Y | N} Suppresses the confirmation prompt that is displayed when the current user does not have the "List Folder" permission on a specified directory, and instead uses the specified default value. Valid values for the /d option are as follows:
- Y: Take ownership of the directory.
- N: Skip the directory.
Note that you must use this option in conjunction with the /r option.
/? Displays help at the command prompt.

Remarks

  • This command is typically used in batch files.
  • 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 takeown command.
  • After deleting the lock with takeown, you might have to use Windows Explorer or the cacls command to give yourself full permissions to the files and directories before you can delete them. For more information about cacls, see "Additional references" at the end of this topic.

Examples

To take ownership of a file named Lostfile, type:
takeown /f lostfile

No comments:

Post a Comment

Note: only a member of this blog may post a comment.

Blog Archive