How to Fix ‘Cannot Delete Key’ Error in Windows Registry
Not sure how to back up your registry? Click here to follow our step-by-step guide on backing up and restoring the Windows Registry.
The ‘Cannot delete (key name): Error while deleting key’ error occurs when the Windows access control system blocks deletion to prevent unauthorized changes. These keys are often protected by the system or owned by TrustedInstaller.
In most cases, this happens because your account does not have ownership or Full Control permissions over the registry key. To fix this issue, you need to take ownership of the key and grant yourself full control permissions, allowing you to delete it.
When you try to delete a registry key, Windows checks the Discretionary Access Control List (DACL) to see whether your account has the required permissions. If not, you must take ownership of the key first and then give your account Full Control permissions. Once these permissions are applied, you should be able to delete the key.
- Click on the Start button, search for Registry Editor, right-click on it, and select Run as Administrator.
- Navigate to the problematic registry key. Right-click on it and select Permissions from the menu.
- In the Permissions window, click on the Advanced button to open advanced security settings.
- In the Advanced Security Settings, click on the Change button next to the Owner field.
- Type your username in the Enter the object name box and click Check Names to validate it. Windows will confirm your username.
- If you are unsure of your username, click on the Advanced button.
- In the next window, click Find Now to list all user accounts. Select your account and click OK.
- Your account will now appear in the object name field. Click OK.
- In the Security Settings window, check the boxes for Replace owner on subcontainers and objects and Replace all child object permissions entries with inheritable permission entries from this object. Click Apply and then OK.
- Click Yes when prompted for confirmation.
- Click OK to close the Advanced Security Settings window.
- Back in the Permissions window, select your user account from the Group or user names list. In the Permissions for users section, check the Allow box next to Full Control. Click Apply and then OK.
- Once you have ownership and Full Control permissions, try deleting the registry key again.