How to Fix SQL Server Uninstallation Error Could Not Open Key
One of my team members was facing issues while installing SQL Server 2017. Unfortunately, some SQL Server files were left on the system from previous SQL Server installations, which we figured out during troubleshooting. We decided to remove all existing components of SQL Server from the system in order to clean the machine before installing SQL Server 2017 again. When we tried uninstalling one of the SQL Server components, we were unable to remove these components because of the below error.
Could not open key: UNKNOWN\Components\425qye###########\547jshy#####. Verify that you have sufficient access to that key or contact your support personnel.
In this article we will cover how we fixed this issue.
We had a requirement to install SQL Server 2017 on a server. The server had already been used to host older versions of SQL Server. The team had uninstalled the older version of SQL Server and tried installing SQL Server 2017. The SQL Server 2017 database engine install failed on this machine because of a conflict with some of the files from SQL Server 2008 that were left during the uninstall process.
The team decided to remove all SQL Server components again before reinstalling SQL Server 2017, but we had an issue when uninstalling one of the SQL Server 2008 components. The uninstall was not successful because of incorrect security settings and users not having access to remove those files. The issue was coming from registry folders and entries. We assign access to one set of folders to try to fix the issue, but then another registry folder appeared the next time during the uninstall.
We knew some registry entries were missed during uninstallation and that was causing the issue. We were not able to track the parent folders to assign the appropriate roles. This might have been left because of inappropriate access on that set of registry entries. Also, the hexa numeric values indicated we should look at the registry level.
There was not just one error we faced. If we tried to assign access to one registry entry then it displayed another hexa numeric folder the next time during uninstallation. It was a very painful and time consuming exercise to try uninstall, then get the next registry address where you needed access and assign the proper role and then repeat the whole exercise again. It was happening in a loop and it was quite frustrating.
We did some research and came to conclusion to set the default Windows security settings to avoid these issues. Maybe somebody modified this server and that was what causing the incorrect permissions on some of the folders, files and registry folders.
Step by Step Approach to Fix this Issue
You can see the above error and observe there is hexa-numeric code given in the error text. All these hexa-numeric value named folders were part of the below registry location and the access issue was coming while accessing these set of folders only.
I am going to explain the step by step process that we took to fix this issue. You can directly go to step 8 to reset the security settings to fix this issue, but I want to explain the approach we took so you can better understand the issue and how Windows applications are integrated at the registry level.
Note: Always take a registry backup before doing anything at the registry level. It is not advisable to play with registry settings. This can corrupt your Windows server so always consult your support experts or seniors before making registry changes.
1 - The issue was related to a hexa-numeric folder name in the registry. Since we knew the issue was partly related to the registry, we opened the registry tree folder and took a backup of the complete registry.
2 - After the backup, we searched the hexa-numeric code in the registry and ended up with a folder name exactly shown in the error code. We right clicked on the folder and selected the "Permission" option to assign the required security access.
3 - Once you click the permission option, you will get another window named "Permission for <FolderName>". As you can see there is no group or user assign to access this folder so first click the "Add" button to add any group or username whom you want to assign the access.
4 - We have added the correct username whom we wanted to assign the access on that registry folder. Generally, this id is the account that is uninstalling the remaining legacy SQL Server files. This can be seen in the below image.
5 - Once you add the user, now assign the appropriate roles to this user by clicking the checkbox as shown below. You can click the Ok button to apply this setting for the registry folder.
6 - Now that we assigned the appropriate roles, in theory this should work now and the uninstallation should be successful. Let’s test it by uninstalling the remaining components again.
You can see we have same issue again, but with a different hexa-numeric code. It means we need to do the same exercise on another folder. This became a very lengthy and time-consuming exercise.
7 - We were using the sysadmin account so there is no question of using a less privileged account to perform these activities. To ensure we had access to the folder at registry level or not, we tried to open the folder which was showing the error. You can see we were not able to open registry folder as seen below.
8 - Finally, to save time and effort, we decided to reset the Windows security settings by executing the below command.
Open a Windows command prompt in administrator mode and run the below command to reset the Windows security settings.
--Run below code on windows command prompt with elevated permission SECEDIT /CONFIGURE /CFG %WINDIR%\INF\DEFLTBASE.INF /DB DEFLTBASE.SDB /VERBOSE /AREAS REGKEYS
This solved the problem and we were able to successfully uninstall the old components and get the newer version of SQL Server installed.
- If you face this issue, hopefully this article gave you some insight as what to look for and a way to solve the problem.
- It is best to always clean the machine before installing a newer version of SQL Server. If possible, install the OS again and then SQL Server to make sure all settings are accurate.
About the author
View all my tips
Article Last Updated: 2020-12-02