Windows has a pretty neat tool; all the way back from Windows 7 and onwards; that lets you take ownership of a file or folder using the command-line interface. This tool is called “Takeown.exe”.
What is meant by Ownership in Windows?
Ownership is in fact, the permission to use a file or folder as well as grant permission to other users to use a specific file or folder. There are different kinds of owners inside Windows. One of them is TrustedInstaller.exe that is a Windows module installer and it enables installation, removal of residual files and modification of Windows Updates. Other owners are SYSTEM and Administrators that have different roles. Administrator is the one who can has full control on files and folders and can assign permissions to other users.
Using Command-Line to Take Ownership of a File or Folder
As mentioned above, Windows has a command-line tool with the name of Takeown.exe that is an easiest and quickest way to change ownership. This a two step process.
- First step: It involves taking ownership of a file/ folder using the takeown command-line function.
- Second Step: In second step, administrator or a logged-on user is provided full control permission of the selected file/ folder.
Steps to Take Ownership of a File
In order to take ownership of a specific file, you need to open Command Prompt using the administrator rights. To do so, type cmd inside Cortana, right click on the Command Prompt desktop app and select Run as administrator. Click Yes when prompted by User Account Control. After that, follow the steps mentioned below.
- In the elevated command prompt, type the following command.
TAKEOWN /F “<filename>”
- Inside above command, you need to replace <filename> with the actual path along with the name of that particular file you want to take ownership of. In my case, I want to take ownership of a 3GP video (dance.3GP) file present in Local Disk D of my hard drive. So, I would type following command including the extension of that particular file.
TAKEOWN /F “D:\dance.3GP”
- If all is well, you would see the following success message.
“SUCCESS: The file (or folder): “filename” now owned by user “Computer Name\User name”.”
Steps to Grant Full Controls/ Permissions to the Selected File
The next step after taking ownership of a file is to grant full control permissions to the selected file. For this, ICACLS function comes in handy. Here is the syntax.
ICACLS “<filename>” /grant %username%:F
Note: If you want to grant permission to the currently logged-on user, type the above command. If the logged-on user is administrator, then above command would automatically detect it and execute the process. If you want to be specific, replace “%username%” with “administrators”.
ICACLS “<filename>” /grant administrators:F
After the command is executed, you would see a success message as in above image.
Steps to Take Ownership of a Folder
Taking ownership of a folder is almost the same as of a file. Type the following command.
TAKEOWN /F “<foldername>” /R /D Y
Replace the <foldername> with the name along with path of the folder you want to take ownership of. All the files present inside the folder will also be owned in this process.
Steps to Grant Full Controls/ Permissions to the Selected Folder
To assign full control to the selected folder, type the following command inside command prompt.
ICACLS “<foldername>” /grant %username%:F /T
Again, replace the <foldername> with your desired one. It will grant full control of the folder and its file to the currently logged-on user.