takeowntakeown

使管理员作为文件的所有者,恢复对之前被拒文件的访问权限。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>/s <computer> 指定远程计算机的名称或 IP 地址, (不要使用反斜杠) 。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>/u [<domain>\]<username> 用指定用户帐户的权限运行脚本。Runs the script with the permissions of the specified user account. 默认值为 "系统权限"。The default value is system permissions.
/p [<[password>]/p [<[password>] 指定在 /u 参数中指定的用户帐户的密码。Specifies the password of the user account that is specified in the /u parameter.
/f <filename>/f <filename> 指定文件名或目录名称模式。Specifies the file name or directory name pattern. 指定模式时可以使用通配符 *You can use the wildcard character * when specifying the pattern. 还可以使用语法 <sharename>\<filename>You can also use the syntax <sharename>\<filename>.
/a/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/r 对指定目录和子目录中的所有文件执行递归操作。Performs a recursive operation on all files in the specified directory and subdirectories.
/d {Y | N}/d {Y | N} 当当前用户对指定目录没有 List Folder 权限,而是使用指定的默认值时,将取消显示的确认提示。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. /D选项的有效值为:Valid values for the /d option are:
  • Y -取得目录的所有权。Y - Take ownership of the directory.
  • N -跳过目录。N - Skip the directory.

    注意NOTE
    您必须将此选项与 /r 选项一起使用。You must use this option in conjunction with the /r option.

/?/? 在命令提示符下显示帮助。Displays help at the command prompt.

备注Remarks

  • 使用 (的混合模式 Mixed patterns using (? takeown命令不支持和 *) 。and *) aren't supported by takeown command.

  • 删除使用 takeown的锁定后,你可能必须使用 Windows 资源管理器向自己提供对文件和目录的完全权限,然后才能删除它们。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

若要获取名为 Lostfile的文件的所有权,请键入:To take ownership of a file named Lostfile, type:

takeown /f lostfile

其他参考Additional References