takeown command cmd

Using Takeown.exe Command to take Ownership of a File or Folder

You can change the owner of a file or folder in Windows through the File Explorer GUI (File > Properties > Security > Advanced > Owner > Change) or using the built-in console utility takeown.exe. In this article we will show you how to take ownership of a file or folder from Command prompt using takeown command. Of course, to change the owner of the file you must be the owner or have the administrator’s permissions.

takeown.exe command

Note. Using the takeown command, you can change object ownership and assign it only to the current user or the local administrator group. The command doesn’t allow you to specify an arbitrary user or group as the owner of the directory or file.

Takeown.exe Command

The takeown.exe utility is located in the C:\Windows\System32 directory, so you do not need to specify the full path to it. The takeown command has the following syntax:

takeown /F <file_name> [/S <RemoteComputerName>] [/U <Domain\DomainUserName>] [/P <UserPassword>] [/A] [/R [/D prompt]]

Parameters of the takeown command:

  • /F <file_name>. Here you must specify the full path to the file or directory whose owner you want to change. You can use the wildcard character *;
  • /S <RemoteComputerName>. You can specify the IP address or the name of the remote computer on which you want to execute the takeown command. By default, the command runs on the current computer;
  • /U <Domain\DomainUserName> and [/P <UserPassword>. Used to specify the credentials of the user under which you want to execute the takeown command;
  • /A. Assign to the owner not the current user (from which the command is running), but the local administrators group. If the parameter is not specified, the ownership is assigned to the current user;
  • /R. Recursively change the owners for all nested files and folders in the specified directory;
  • /D {Y | N}. If the current user doesn’t have permission to view the contents of the directory (list files NTFS permissions), this parameter specifies whether to change the owner of the file. Y – change owner, N – skip files.

Full syntax and help on the takeown command can be obtained as follows:

takeown /?


Let’s look at some examples of using the takeown command.
Assign yourself to the owner of the C:\PS directory:

takeown /F "C:\PS"

takeown command

When executing these command, you will receive a message that you successfully become the owner of a particular objects in the specified folder.

After you have assigned yourself as the owner, you will be able to access the folder. If other users access this folder, you need to check and change the NTFS access permissions using the icacls utility or File Explorer.

Assign yourself to owning the permissions.log file on the remote computer:


takeown /F "C:\permissions.log " /S lonPC2213.theitbros.com

Assign a group of administrators to the owner of all text files in the Windows directory:

takeown /F %windir%\*.txt /A

Assign the ownership to the group of local administrators owners at all nested files and folders, skip the directories to which the user doesn’t have access permissions:

takeown /F C:\PS\ /A /R /D Y

Assign current user the owner of all *.docx files in the shared folder Public on the manfs01 file server:

takeown /S manfs01 /F Public \*.docx

Tip. Do not reassign the owner to root system folders (C:\Windows, C:\Program Files, etc.) or for the entire system partition – you can damage your Windows installation.

You may also like:

Using Nslookup Command to Check DNS Servers and Re... Nslookup (name server lookup) is a command-line utility that is used to diagnose and verify DNS servers and records, and detect problems with resolvin...
GPT or MBR: How to Check HDD Partition Table Style The modern versions of Windows and other operating systems can use one of two standards to store information about hard disk partitions structures. Th...
IPCONFIG: How to Release a Renew IP Address in Win... On Windows operating systems, the ipconfig utility is used to get different information about the current TCP/IP protocol settings, release or renew t...

Add Your Comment