Have you ever encountered a situation where you couldn’t access or modify a file or folder on your Windows computer because of permission issues? If so, you’re not alone.
Windows operating systems are designed with robust security features to protect your data, and this sometimes results in frustrating scenarios where you need to take ownership of a file or folder to gain full control.
Thankfully, Windows provides a handy command-line tool called Takeown.exe that allows you to do just that. In this blog post, we’ll explore what Takeown.exe is, how it works, and how you can use it to take ownership of files and folders on your Windows system.
Related. Learn how to change a file or folder ownership using Get-Acl and Set-Acl.
Table of Contents
What is Takeown.exe?
Takeown.exe is a built-in command-line utility in Windows that allows users to take ownership of files and folders on their computers. Ownership refers to the right to control and manipulate a file or folder’s permissions, which can be crucial when encountering “access denied” or permission-related errors.
By taking ownership of a file or folder, you can gain full control, including the ability to change permissions, delete, or modify it as needed.
One limitation of the Takedown.exe command is that it does not allow you to specify an arbitrary user or group as the owner of the directory or file. It can only assign ownership to the currently logged-on user or the local administrators’ group.
Why Would You Need to Use Takeown.exe?
There are several scenarios in which you might need to use Takeown.exe:
- Access Denied Issues: When you’re denied access to a file or folder due to insufficient permissions, even though you’re an administrator on the computer.
- File Recovery: To recover files from an old user profile or a system backup.
- System Tweaking: For advanced users who want to modify system files or folders for customization or troubleshooting purposes.
Takeown.exe Options and Parameters
Takeown.exe has several options and parameters that allow you to customize its behavior according to your needs. Understanding these options is crucial for using the tool effectively. Here are the key options and parameters:
- /S <system>:
- The remote system to connect to, such as another client machine or a server.
- /F <filename or directory>:
- Specifies the file or folder path you want to take ownership of.
- Example for a file:
takeown /f "C:\path\to\file.ext"
- Example for a folder (including subdirectories):
takeown /f "C:\path\to\folder" /r /d y
- /R:
- Makes the Takeown.exe command apply recursively to all files and subfolders within the specified folder. This is useful when you want to take ownership of an entire directory tree.
- Example:
takeown /f "C:\path\to\folder" /r /d y
- /D {Y|N}:
- Specifies the default answer for all prompts. When set to y, it assumes “Yes” as the answer to all confirmation prompts, making the process more automated.
- Example:
takeown /f "C:\path\to\folder" /r /d y
- /A:
- Allows administrators to take ownership of a file or folder even if they are not listed as the current owner. This option is handy for system administrators who need to manage network or shared drive permissions.
- /U [domain\]username:
- Specifies the username or user account for which ownership will be taken. By default, it uses the currently logged-in user account.
- Example:
takeown /f "C:\path\to\file.ext" /u "username"
- /P <password>:
- Specifies the password for the user context used in /U.
- /SKIPSL:
- Skip symbolic links. To be used with /R.
- /?:
- Displays information about the available options and usage of the Takeown.exe command.
These options and parameters provide flexibility and control when using Takeown.exe. Depending on your specific situation, you can tailor the command to suit your needs, whether taking ownership of a single file, a folder, and its subcontents or automating the process with predefined answers to confirmation prompts.
How to Use Takeown.exe (Examples)
Using Takeown.exe is relatively straightforward. Here are some usage examples.
Take Ownership of a File or Folder as the Current User
Here are the steps to take ownership of a file or folder:
- Open Command Prompt as Administrator:
To use Takeown.exe, you need administrative privileges. Right-click on the Start menu, and select “Command Prompt (Admin)” or “Windows Terminal (Admin)” if you’re using Windows 10 or later. - Navigate to the File or Folder Location:
Use the cd command to navigate to the directory where the file or folder you want to take ownership of is located.
Related post. Navigating the Filesystem with PowerShell Change Directory Commands.
- Run the Takeown.exe Command:
To take ownership of a file, use the following command:takeown /f "C:\path\to\file.ext"
- To take ownership of a folder and its contents, use this command:
takeown /f "C:\path\to\folder" /r /d y
- /f specifies the file or folder path.
- /r makes the command recursive, allowing it to apply to all files and subfolders within the specified folder.
- /d y assumes “Yes” as the answer to all prompts (useful for batch operations).
- Verify Ownership:
You can verify if ownership has been successfully transferred by running the dir /q command:dir "C:\path\to\folder" /q
You can also use the ICACLS command.
Assign Ownership of a File or Folder to the Local Administrator Group
To assign the ownership of a file or folder to the local administrators, use the /A parameter.
Assign ownership of one file to the local administrator group.
takeown /f "C:\path\to\file.ext" /A
Assign ownership of a folder and all its contents to the local administrator group.
takeown /f "C:\path\to\folder" /A /r /d y
Take Ownership of a File or Folder on a Remote System
You can also use Takeown.exe to take ownership of a file or folder (and its contents) on a remote system, provided you have sufficient privileges.
For example, this command takes ownership of the file C:\demo\computers.txt on the remote system DC1.
takeown.exe /f C:\demo\computers.txt /s DC1
You can also specify the user account context under which the Takeown.exe command runs. In this example, the ownership will be assigned to the currently logged-on user, but the “theitbros\ebrown” administrator account will be used to implement the ownership takeover.
takeown.exe /f C:\demo\computers.txt /s DC1 /u "theitbros\ebrown" /p "VX4qh@Js8&xBs43y"
Tip. Do not reassign the owner of the root system folders (C:, C:Files, etc.) or the entire system partition; otherwise, you can damage your Windows installation.
When All Else Fails, Use Takeown.exe with PsExec
Sometimes, despite your best efforts, you just can’t take ownership of a folder or file, even as the local administrator account. When Takeown.exe fails with “INFO: Access is denied”, don’t lose hope.
In this situation, you try to run Takedown.exe using the local “NT AUTHORITY\SYSTEM” account with PsExec.
- Download the PSTools archive and extract it to a directory on the local drive. In this example, it is extracted to “C:\pstools”.
- Open the command prompt as an administrator and navigate to the PSTools directory:
cd c:\tools\pstools
- Start an instance of cmd.exe as the System account by running this command:
PsExec.exe -ids cmd.exe
- Now, you can run Takeown.exe in the new instance of the command prompt:
Conclusion
Takeown.exe is a valuable tool in your Windows administration arsenal when encountering file or folder permission issues. By understanding how to use it properly, you can regain control over your files and folders, troubleshoot permission-related errors, and manage your system more effectively.
Use it responsibly and be cautious when working with critical system files.
3 comments
Access denied memory card. Access denied displayed in a camera. After that windows can’t access the SD card
Brilliant page – very good description. Friend of mine was moaning not much info on net about Takeown.exe – so I strongly berated him and told him to look at this site…
I did this so I could try and replace ntdll.dll to fix a game crash, but I was still denied permission… as the sole user on my computer.