Click here to Skip to main content
15,881,172 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello friends,

I am new to c#.

I am trying to make a program that can store my software related information in the system registry.
When I am trying to write the registry with c# code, it gives permission error; unable to write the registry.

Please give me a solution.

I am using this code with windows 7 and VS 2010.

Thank you in advance.
Posted
Updated 28-Nov-18 10:02am
v2
Comments
Dalek Dave 6-Sep-10 4:23am    
Edited for Readability and Grammar.
Richard MacCutchan 6-Sep-10 5:18am    
Which key are you trying to update? Please show your code and the exact key that you are attempting to write.

The registry is protected space so your application needs to run with administrator privilege. Right click your app and select "Run as administrator".
 
Share this answer
 
Comments
darora85 6-Sep-10 4:22am    
friend,
i am already running with the admin privilege, but it is not allowing to write the registry.Can this work be done by c# code also(getting admin privilege).
CPallini 6-Sep-10 4:28am    
I believe your statement is valid just for some parts of the registry, like HKLM.
Dr_armin_R 29-May-11 2:36am    
Yes, So true.
I tried to write on "HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Run" but I couldn't ! Once I changed to HKCU there was no problem. It seems there exists some kind of Proxy.
Hello,
Open the registry editor, click the start key and select run.
then type regedit and click ok.
When thr registry is open right click on the HKLM and choose permissions.
when the window comes up if you see Administrators click on it and then check
the box under allow, full control.

then that should do the trick
 
Share this answer
 
Comments
Dave Kreskowiak 28-Nov-18 16:31pm    
That's a really bad "solution" to an 8 year old question. This "solution" isn't a solution at all and will prevent apps demanding this "solution" from being used in an enterprise environment.

Modifying security to get around a poor design practice is never a good idea.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900