Darren Kattan
asked on
C# Registry Permission can't Write to Registry
I'm trying to make a program that will write to a particular registry Key that "Everybody" doesn't have full control over.
Here's the basic Gyst of the code:
RegistryKey key2 = Registry.LocalMachine.Open SubKey("SY STEM\\Curr entControl Set\\Enum\ \FTDIBUS\\ VID_0403+P ID_6001+5& 138461b1&0 &1\\0000", true);
This particular key inherits its security settings from the Enum Key.
If I run the same line without the true on the end, it goes past this line, but hangs whenever I try to write to the key.
I can successfully write to other keys/values with no problem.
Here's the kicker. If I go into RegEdit, I can set the permissions manually so that Everyone has Full Access to this key, the program works without a hitch.
Currently only SYSTEM has Full Access.
I plan on deploying this to many computers, so I need a way for the program to Change the Permissions for that Key. I'm assuming if the person running the program has Admin Access, then I should be able to accomplish this.
I have tried inserting:
[assembly: RegistryPermissionAttribut e(Security Action.Req uestMinimu m, Write=@"HKEY_LOCAL_MACHINE \\SYSTEM\\ CurrentCon trolSet\\E num")]
at the beginning, but that doesn't do anything.
I've fooled with with RegistryAccessRules, and I've made a Rule that will accomplish what I want, but I have no earthly idea how to apply that rule to the registry key if it isn't open in write mode (true at the end);
I would greatly appreciate any help at all with this.
Here's the basic Gyst of the code:
RegistryKey key2 = Registry.LocalMachine.Open
This particular key inherits its security settings from the Enum Key.
If I run the same line without the true on the end, it goes past this line, but hangs whenever I try to write to the key.
I can successfully write to other keys/values with no problem.
Here's the kicker. If I go into RegEdit, I can set the permissions manually so that Everyone has Full Access to this key, the program works without a hitch.
Currently only SYSTEM has Full Access.
I plan on deploying this to many computers, so I need a way for the program to Change the Permissions for that Key. I'm assuming if the person running the program has Admin Access, then I should be able to accomplish this.
I have tried inserting:
[assembly: RegistryPermissionAttribut
at the beginning, but that doesn't do anything.
I've fooled with with RegistryAccessRules, and I've made a Rule that will accomplish what I want, but I have no earthly idea how to apply that rule to the registry key if it isn't open in write mode (true at the end);
I would greatly appreciate any help at all with this.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.