Can't delete Registry.LocalMachine subkey

P

Peri

I can delete Registry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\Application\Eurotax");
eurotaxKey.DeleteSubKey("pathDat");

I am administrator and regedit shows me that 'Administrators' have full
control
on Eurotax key. I've also given 'All users' full control to this key and
still I get System.UnauthorizedException with message "Cannot write to the
registry key".

There's no problem deleting from Registry.CurrentUser.
 
A

Alvin Bruney [MVP]

I assume this is from a C# app? Do you have registry permissions configured
correctly in CAS?

--
Regards,
Alvin Bruney
------------------------------------------------------
Shameless author plug
Excel Services for .NET is coming...
OWC Black book on Amazon and
www.lulu.com/owc


I can delete Registry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\Application\Eurotax");
eurotaxKey.DeleteSubKey("pathDat");

I am administrator and regedit shows me that 'Administrators' have full
control
on Eurotax key. I've also given 'All users' full control to this key and
still I get System.UnauthorizedException with message "Cannot write to the
registry key".

There's no problem deleting from Registry.CurrentUser.
 
W

Willy Denoyette [MVP]

I can delete Registry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\Application\Eurotax");
eurotaxKey.DeleteSubKey("pathDat");

I am administrator and regedit shows me that 'Administrators' have full
control
on Eurotax key. I've also given 'All users' full control to this key and
still I get System.UnauthorizedException with message "Cannot write to the
registry key".

There's no problem deleting from Registry.CurrentUser.

--
Peri



Your subkey is open for reading only, you have to open the subkey as "Writable", use the
overload of OpenSubKey that takes a boolean flag as second argument and set this one to
true.

Willy.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top