If when you try to delete a registry key in Windows 10, Windows 8.1, Windows 8, Windows 7 or Windows Server, you are unable to delete it and you get an error message: Error while deleting key, then this article may interest you.
Error while deleting Registry key
This can be caused if you attempt to delete a registry key that contains embedded null characters. These characters are not visible when viewing the registry entry.
To delete a registry key that contains an embedded null character, you must first replace the null character with another character.
Use Systernals RegDelNull tool
You can accomplish this by using the RegDelNull tool from Sysinternals.
This command-line utility searches for and allows you to delete Registry keys that contain embedded-null characters and that are otherwise undeletable using standard Registry-editing tools. Note: deleting Registry keys may cause the applications they are associated with to fail.