|
-
Jan 31st, 2008, 10:17 PM
#1
Thread Starter
New Member
UnauthorisedAccessException
Hi ,
I am trying to change the datavalue of a registry key using dotnet c#
The code i use is as follows
RegistryKey key = Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Shared Tools\\Web Server Extensions\\12.0\\WSS");
if (key != null)
{
key.SetValue("SetupType","V2V_INPLACE_UPGRADE");
f1.Logger("Registry value in the key SetupType is succesfully set as V2V_INPLACE_UPGRADE");
}
How ever i am not able to set the value as an unhandled exception gets thrown UnauthorisedAccessException saying i dont have the access privileges .
how ever i am the administrator and i am able to change the registry settings manually .
kindly help me out regarding this .
Thanks in advance
have a nice day
-
Jan 31st, 2008, 10:31 PM
#2
Re: UnauthorisedAccessException
Read the MSDN documentation for the OpenSubKey method. Pay particular attention to the description of the overload you're calling:
 Originally Posted by MSDN
Retrieves a subkey as read-only.
-
Feb 1st, 2008, 12:30 AM
#3
Re: UnauthorisedAccessException
Moved and duplicate thread removed
-
Feb 1st, 2008, 02:13 AM
#4
Re: UnauthorisedAccessException
I had replied to the duplicate thread that was removed so I'll repost that info here. As I have already said, the OpenSubKey method you're calling opens the key read-only. As you'd expect, writing to a read-only key is a no-no. So, doing as I said and going to the MSDN documentation for the OpenSubKey method you'll see that there are several overloads. You know the one you're calling is no good so look at the others. Do any of them allow you to open the key without the read-only restriction?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|