473,388 Members | 1,552 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Can't delete Registry.LocalMachine subkey

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
3 7774
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
"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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Ed P. | last post by:
hello, I want to check to see if a certain registry key exists on the registry. What's the easiest way to do this. Here is what I am currently doing. private string registryKey =...
4
by: James | last post by:
I am trying to read values to the subkeys under HKLM\...\Uninstall. I get to this point... RegistryKey Sftw = RegistryKey.OpenRemoteBaseKey(RegistryHive.LocalMachine,...
3
by: Slimo | last post by:
Hello, I'm searching some example of code (VB) for reading remote registry subkeys and keys. Thanks
4
by: Cal | last post by:
The Help examples for creating a Registry subkey uses double backslashes between subkeys. The examples for creating a folder use a single backslash. First: Am I right in that double...
0
by: sxzy | last post by:
Hi, I use OpenRemoteBaseKey to open HKLM key on remote machine in same domain Code fails on OpenSubKey with error "Requested registry key is not allowed" I tried to give permissions to...
5
by: Parv | last post by:
I am working in a domain environment. I am on a client machine and wants to edit registery of domain server. I am currently in a Domain user account and member of Domain administrators on the...
2
by: Peri | last post by:
I can delete Registry.LocalMachine subkey using regedit. But not using code: RegistryKey eurotaxKey = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Firm\Application\Eurotax");...
3
by: YXQ | last post by:
Hello, I need to programmatically take ownership of a registry-key as current user using VB2005. To test this , i created a key HKEY_LOCAL_MACHINE\Software\TestKey and removed all accessrights...
3
by: thephatp | last post by:
This is incredibly strange. I used regedit and went to HKEY_LOCAL_MACHINE and create a new subkey under "Software". I added a few more, then went into code to try to read them. I kept getting...
5
Sl1ver
by: Sl1ver | last post by:
I have this piece of code public bool Write(string KeyName, object Value) { try { // Setting string subKey1 =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.