Reputation: 11
RegistrySecurity rs = new RegistrySecurity();
RegistryKey rk =
RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry32).
OpenSubKey("SOFTWARE\\MyApplication", true);
rs.AddAccessRule(new RegistryAccessRule("Everyone",
RegistryRights.WriteKey | RegistryRights.ReadKey | RegistryRights.Delete,
InheritanceFlags.None,
PropagationFlags.None,
AccessControlType.Allow));
I am trying to give writable permission to all system user for particular folder under SOFTWARE from registry. but i couldnt do this using C# code. please let me out from this fix.
Upvotes: 1
Views: 684
Reputation: 1046
//Complete solution:
RegistrySecurity rs = new RegistrySecurity();
RegistryKey rk = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\ASUS", true);
rs.AddAccessRule(new RegistryAccessRule("Everyone", RegistryRights.WriteKey | RegistryRights.ReadKey, InheritanceFlags.None, PropagationFlags.None, AccessControlType.Deny));
if(rk != null)
{
rk.SetAccessControl(rs);
}
Upvotes: 3