Technical Notes

Follow

Advertisement

Fix Cannot Delete Error While Deleting Key in Windows 10

Share

At times, you may need to delete a registry key from the registry editor. To to delete a registry key from the registry editor, you need to assign full permission and control on a registry key. If you don’t do this, you may end up with an error message “Cannot delete  (key name): Error while deleting key”. This is a not OS specific issue as it can occur on Windows 7, Windows XP, Windows 8.1 and Windows 10. So, in today’s post, we will be showing you how to fix cannot delete error while deleting key in Windows 10.

I recently got a message saying that the user was experiencing the issue while trying to delete a registry key. The error the reader was facing while trying to delete the registry key was for Bluestacks. The error was “Cannot delete Bluestacks: Error while deleting key”. As you can see Bluestacks is the registry key here and the user was unable to delete it.

You may want to delete registry keys any time. Most of the time, this could be because you want to reinstall a software that has malfunctioned or is not working properly and the only way to make it work is to reinstall it. Since the registry keys may remain even after the uninstallation, it can create problems during reinstallation.

Now to fix “cannot delete key: error while deleting key” you need to assign full permission to the registry key. Once you have taken the ownership, you can try deleting the registry key. The error can also occur due to other reasons as well. So, try all the fixes listed below until the error gets resolved.

Fix Cannot Delete Error While Deleting Key

Advertisement

Note: This tutorial can be applied to Windows 7, Windows 8.1 and Windows 10 OS running PCs.

Take Ownership and Grand Full Permission to the Registry key.

There are two ways to grant permission and take ownership of a registry to fix ” Cannot Delete Error While Deleting Key”. You can do this directly from the registry editor, or you can do this using the command prompt. I have listed both the methods in the article.

Method 1: Take Ownership of a Registry Key using Registry Editor

Note, if you are running Windows 7 or below, the procedure to take the permission is different compared to Windows 8 and Windows 10. So, check steps mentioned for your version of Windows OS.

>> For Windows 10 / 8.1 / 8
Advertisement

Press “Windows Key + R”, it will open the Run dialogue box. In the Run dialogue box type “regedit” and hit enter. It will open “Registry Editor” window.

Now go to the registry key that you want to take permission. Right-click on it and “Permission” from the options.

Registry Editor Permissions option

A new “Permissions for Display” dialogue box will open. In the dialogue box, click on the “Advanced” button at the bottom.

Permissions security

Click on “Change” link beside Trustedinstaller. It will open a  new dialogue box “Select User or Group”.

Advertisement
Advanced security settings for shell owner trustedinstaller

Enter your username in “Enter the object name to select” and click on “Check Names” button. It will automatically check and convert the username to correct format.

Check Name select the user

Click on the OK button to save the settings.

Now in “Permissions for Display” window, select your username under “Group or user name:” and check “Allow” checkbox in front of “Full Control”.

Full Control System
Advertisement

Click on Apply button and then on the OK to save the settings. That’s it. You have taken full permission for the registry key and now can delete the registry key if you want.

>> For Windows 7 / XP / Vista 

Open registry editor by pressing “Windows key + R”, type “regedit” and hit enter.

Now navigate to the registry key that you want to take permission. Right-click on the key and select “Permissions” from the option.

Click on the “Advanced” button at the bottom.

Click on the “Owner” tab. Here you can see the Current owner and change owner to option.  Under “change owner to ” select your username and click on “Apply” button. At the bottom, you can also see “Replace owner on subcontainers and objects” option. Check this option if you want to take ownership of the sub-key

Advertisement

Now in “Permissions for Display” dialogue box, select your username and check “Allow” option for “Full Control“. Click on Apply and then on the OK button to save the settings.

Method 2: Take Ownership of Registry Using Command prompt

If you are comfortable with the commands and the command prompt then you can use the method 2 to take grant permission to the registry keys. The Command prompt method has various way to grant permission to a registry key with different tools, but for this post, I will not be going in detail as I will cover using the command prompt to take ownership in detail in my next post. Follow these steps to take ownership of a registry key using the command prompt.

1. Download SetACL Utility from here– This is required to grant and assign permission using the command prompt.

Once downloaded, extract the downloaded file. It has two versions for 32-bit and 64-bit, so select the version according to your OS version.

2. Move the (32-bit or 64-bit) SetACL.exe file to C:/Windows/Sytem32 folder.

Advertisement

3. Now open command prompt as administrator and enter the following commands:

SetACL.exe -on "HKEY_CLASSES_ROOT\bittorrent\shell" -ot reg -actn setowner -ownr "n:Administrators"
SetACL.exe -on "HKEY_CLASSES_ROOT\bittorrent\shell" -ot reg -actn ace -ace "n:Administrators;p:full"

In the above command, change “HKEY_CLASSES_ROOT\bittorrent\shell” with your desired registry or file path or location. You can find the Key name by right-clicking on the registry in the registry editor and selecting “Copy Key name” option.

Taking Permission using command prompt

If you see “SetACL finished successfully” message for both the commands then you can be sure that you have taken ownership permission for the registry key.

Now try to delete the registry key and see if the error “Cannot delete key: Error while deleting key” has been resolved.

So, this was about how to fix the “Cannot delete Error while deleting key”. Do let us know if you have an alternative fix in the comments below.

Advertisement

Share

Related

Advertisement

Latest

Advertisement