Does anyone know how to get access to a Registry key and delete all Subkeys?

  • Thread starter Thread starter DaveM121
  • Start date Start date
D

DaveM121

Guest
Hi developers,

I need to gain access to this Registry key and delete all sub keys, but I keep getting a permission error

This is the actual Registry Key that I want to remove ll the sub keys from:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\NetworkList\Profiles


This is the code that is throwing an error:

If I use this code, I get a permissions Error

RegistryKey aRegkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList", true);


If I add the profiles Key, i Get a Null reference:

RegistryKey aRegkey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkList\\Profiles", true);


I think I have to do something like this to get security permissions . . .

var security = aRegkey.GetAccessControl();
var rules = security.GetAccessRules(true, true, typeof(System.Security.Principal.NTAccount));


Any Help would be greatly appreciated :))


DaveM121

Continue reading...
 
Back
Top