CraigLazar
asked on
VB.NET 2008 Delete reg key Access error
Hi,
I have created a 1 button app that must simply delete a key and its sub keys from the registry in the LocalMachine section. But i am getting an access error.
{"Requested registry access is not allowed."}
Security Exception was caught.
Dim x As Microsoft.Win32.RegistryKe y
x = Microsoft.Win32.Registry.L ocalMachin e.OpenSubK ey("SOFTWA RE\Test1", True)
x.DeleteSubKeyTree("Testin g")
The exception is being generated on line 2 of my code. Is there perhaps another way of doing it? (I have admin wrights on my machine Win7) I need to cater for XP,Vista and Win7n machines
thanks
I have created a 1 button app that must simply delete a key and its sub keys from the registry in the LocalMachine section. But i am getting an access error.
{"Requested registry access is not allowed."}
Security Exception was caught.
Dim x As Microsoft.Win32.RegistryKe
x = Microsoft.Win32.Registry.L
x.DeleteSubKeyTree("Testin
The exception is being generated on line 2 of my code. Is there perhaps another way of doing it? (I have admin wrights on my machine Win7) I need to cater for XP,Vista and Win7n machines
thanks
where have you defined the subkeytree "Testing" thatyou are trying to delete?
ASKER
Hi,
I am getting the error on the following line before i even attempt to delete the sub key
x = Microsoft.Win32.Registry.L ocalMachin e.OpenSubK ey("SOFTWA RE\Test1", True)
I am getting the error on the following line before i even attempt to delete the sub key
x = Microsoft.Win32.Registry.L
have you written that key?
Try the following to see what the value of the key is. If it is "0" then the value is not present
Try the following to see what the value of the key is. If it is "0" then the value is not present
Dim uKey As RegistryKey = Registry.LocalMachine.OpenSubKey("SOFTWARE\Test1", True)
Dim cKey As String = CStr(uKey.GetValue("Testing", "0"))
ASKER
hi,
ok i tried ur code, but throws exception 'Requested registry access is not allowed'
ok i tried ur code, but throws exception 'Requested registry access is not allowed'
what platform are you running the code on? Win7?
ASKER
win7 x64 VS2008
Have you turned UAC off?
With UAC on Windows 7 even a user with admin rights cannot access the HKLM tree for writing.
Do you have the same problem with a key in HKCU?
With UAC on Windows 7 even a user with admin rights cannot access the HKLM tree for writing.
Do you have the same problem with a key in HKCU?
ASKER
Hi,
I turned UAC off and still same error.
I turned UAC off and still same error.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks