I am working on file associations. I determined that there is a key called UserChoice
in:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Explorer\FileExts\[ext].
I managed to read and write the UserChoice
key, provided that I create it and that it has not yet been created by Windows. However, if the UserChoice
key UserChoice
already been created by Windows, then I need to run as Administrator to gain access to the key. My ultimate goal is to remove the UserChoice
key.
I noticed that Windows places the Deny rule on the UserChoice
key, which prevents me from deleting this key. If I can remove this rule, I believe that I will remove the UserChoice
key. Here is the code I tried:
public static void ShowSecurity(RegistryKey regKeyRoot, string user) { RegistrySecurity security = regKeyRoot.GetAccessControl(AccessControlSections.All); foreach (RegistryAccessRule ar in security.GetAccessRules(true, true, typeof(NTAccount))) { if (ar.IdentityReference.Value.Contains(User) && ar.AccessControlType.ToString().ToLower() == "deny") { security.RemoveAccessRuleSpecific(ar); regKeyRoot.SetAccessControl(security); } } }
When Windows creates a UserChoice
key, it adds a security rule for the current Type Deny user ; Resolution: special . This rule is not inherited and applies only to the UserChoice
key.
With some startup and startup as an administrator, I can access this RegistryAccessRule
. However, even as an administrator, I cannot delete this rule. I read somewhere in my research that there is no software way to do this. I can remove this rule through RegEdit. I can also remove the UserChoice
key using the file type manager from NirSoft. Therefore, I suppose there is a way to do this.
Summary: Is there a way to remove the Deny rule so that I can remove the UserChoice
key?
Scruffyduck
source share