Introduction#
Have you ever encountered the frustrating message "You need permission to perform this action" when trying to delete or modify a file/folder on your Windows computer, requiring SYSTEM or TrustedInstaller permissions? This permission issue is particularly common with leftover files from system updates, program installation directories, or certain protected system files.
Manually navigating through properties → security → advanced → change owner → replace owner on subcontainers and objects... this series of operations is not only cumbersome and time-consuming but also quite unfriendly for the average user.
This article will introduce a one-time solution: by adding a "Take Ownership" right-click menu item, making permission management simple and efficient.
Overview of the Principle#
Windows' permission system is based on Access Control Lists (ACLs), with each file and folder having specific owners and permission settings. Our solution adds a custom right-click menu item through the registry, which automatically executes two core commands when the user selects this option:
- takeown - Take ownership of the file or folder
- icacls - Modify the access control list to grant full control permissions to the administrators group
Installation Method#
Step 1: Create a Registry Script#
- Create a new text document
- Copy the following code completely into the document:
Windows Registry Editor Version 5.00
[HKEY_CLASSES_ROOT\*\shell\runas]
@="Take Ownership"
"Icon"="cmd.exe"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\*\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" && icacls \"%1\" /grant administrators:F"
[HKEY_CLASSES_ROOT\Directory\shell\runas]
@="Take Ownership"
"Icon"="cmd.exe"
"NoWorkingDirectory"=""
[HKEY_CLASSES_ROOT\Directory\shell\runas\command]
@="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
"IsolatedCommand"="cmd.exe /c takeown /f \"%1\" /r /d y && icacls \"%1\" /grant administrators:F /t"
Step 2: Save and Run#
- Save the file as
Take_Ownership.reg
(ensure the file extension is .reg and not .txt) - Double-click to run this file
- When prompted by the system to confirm adding information to the registry, click "Yes"
- After seeing the success message, click "OK"
User Guide#
Once installed, you just need to:
- Find the file or folder you need to take ownership of
- Right-click on that object
- Select the "Take Ownership" option
- Wait for the command window to flash (indicating the operation is complete)
- You can now operate on that file or folder normally
Safe Uninstallation Method#
If you later need to remove this right-click menu item, please create and run the following uninstallation script:
Windows Registry Editor Version 5.00
; Remove the right-click menu item for [Files]
[-HKEY_CLASSES_ROOT\*\shell\runas]
; Remove the right-click menu item for [Folders]
[-HKEY_CLASSES_ROOT\Directory\shell\runas]
Save the above content as Uninstall_Take_Ownership.reg
and run it to completely remove this feature without affecting the system in any other way.
Notes#
- Use with Caution: While this tool is convenient, please do not take ownership of critical system files unless you are certain of what you are doing.
- Scope of Functionality:
- For files: Only affects the single file
- For folders: Will recursively affect all subfolders and files within that folder
- Permission Restoration: After the operation, you may need to refresh or reopen File Explorer to see the changes.
- System Compatibility: This method is applicable to all versions of Windows 7, 8, 10, and 11.
Conclusion#
By adding the "Take Ownership" right-click menu item, we have greatly simplified the cumbersome permission management process in Windows. This small trick can save you a lot of time and effort, especially when needing to clean up leftover system files or modify protected system settings.
It is recommended to keep the installation and uninstallation scripts in a safe location (e.g., D:\System Tools) for easy management in the future.
Copyright Statement: This article is licensed under CC BY-NC-SA 4.0. Please cite the source when reprinting.
Disclaimer: The tips provided in this article are for learning reference only, and the author is not responsible for any system issues that may arise from using the methods described. Please ensure you have backed up important data before proceeding.