How To Use Takeown — Command
| Option | Description | |--------|-------------| | /f | Specifies the file or folder path (required) | | /r | Recursive - all subfolders and files | | /a | Give ownership to Administrators group | | /d | Default answer for prompts (y/n) | | /skip | Skip files with access errors |
Here are some best practices to keep in mind when using the takeown command:
/r = recursive (all subdirectories and files)
takeown /f C:\Users\OldUser /r
To take ownership of a specific file as the currently logged-in user: takeown /f C:\path\to\file.txt 2. Take Ownership of a Folder and All Subcontents
: You must open the Command Prompt or PowerShell with administrative privileges, or the command will fail.
: Specifies the file/folder or pattern (wildcards allowed). how to use takeown command
⚠️
Once you own the file, you can then use the icacls command to grant yourself full control permissions. 💻 Basic Syntax
: Performs a recursive operation (includes all files and subfolders). | Option | Description | |--------|-------------| | /f
Taking ownership only makes you the "Owner." It does automatically give you permission to read or write the file. You must follow up with the icacls command to grant yourself permissions. The "One-Two Punch" Combo: takeown /f "C:\TargetFolder" /r /d y icacls "C:\TargetFolder" /grant administrators:F /t
If you want any admin on the PC to have access, use the /a switch: takeown /f "C:\SystemFiles" /a /r /d y ⚠️ Important: The Second Step (icacls)