By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,983 Members | 1,110 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,983 IT Pros & Developers. It's quick & easy.

Can't delete Registry.LocalMachine subkey

P: n/a
I can delete RCan't delete Registry.LocalMachine
subkeyegistry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\A pplication\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
Jan 31 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
It may be to do with the CLR permissions that have been set.
What is the application type (web app/winform/service)

--
Ciaran O''Donnell
http://wannabedeveloper.spaces.live.com
"Peri" wrote:
I can delete RCan't delete Registry.LocalMachine
subkeyegistry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\A pplication\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
Jan 31 '07 #2

P: n/a
"Peri" <em***@server.netwrote in message news:op***************@at-piotrpe.atena.pl...
I can delete RCan't delete Registry.LocalMachine
subkeyegistry.LocalMachine subkey using regedit. But not using
code:
RegistryKey eurotaxKey =
Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\A pplication\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

As I said in another reply you need to call OpenSubKey with the Writable flag set to true
like this:

Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\A pplication\Eurotax", true);

Willy.
Jan 31 '07 #3

P: n/a
"Ciaran O''Donnell" <Ci************@discussions.microsoft.comwrote in message
news:4E**********************************@microsof t.com...
It may be to do with the CLR permissions that have been set.
What is the application type (web app/winform/service)
Not at all, System.UnauthorizedException "Cannot write to the
registry key", is a Windows permission issue not a code access issue.

Willy.

Jan 31 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.