How to change registry key permissons from a C#
-
Hi, how do I change the Registry-Key permissons from my own tool? Under Vista the Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing is owned by the trusted installer and so also Administrators only have read permissions. But I must write into the Key. So, how do I change the permissions for the admin group to full access? Is there a function to do this? thx André
'A programmer is just a tool which converts caffeine into code'
-
Hi, how do I change the Registry-Key permissons from my own tool? Under Vista the Key HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing is owned by the trusted installer and so also Administrators only have read permissions. But I must write into the Key. So, how do I change the permissions for the admin group to full access? Is there a function to do this? thx André
'A programmer is just a tool which converts caffeine into code'
There are no managed code functions that can do this. You could do this by using some interop to the native API's, but I don't recommend it. Why do you need to write to this key any time other than at install time? If you just need to store run-time information, there are other registry keys that your application has access to that you should be using instead. If you actually need to change this key, you need to learn how to do it the correct way and play properly within the permissions by using a manifest file for your application and splitting that feature out into a separate module (application) that can run with elevated privileges or make your entire application require elevated privs to run (not recommended as well).
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
-
There are no managed code functions that can do this. You could do this by using some interop to the native API's, but I don't recommend it. Why do you need to write to this key any time other than at install time? If you just need to store run-time information, there are other registry keys that your application has access to that you should be using instead. If you actually need to change this key, you need to learn how to do it the correct way and play properly within the permissions by using a manifest file for your application and splitting that feature out into a separate module (application) that can run with elevated privileges or make your entire application require elevated privs to run (not recommended as well).
Scott.
—In just two days, tomorrow will be yesterday. [Forum Guidelines] [Articles] [Blog]
Hi Scott,
Scott Dorman wrote:
Why do you need to write to this key any time other than at install time?
Sorry can't talk about it, but I must add a key into this folder. What are the Win32 API functions to change the permissions? André
'A programmer is just a tool which converts caffeine into code'
-
Hi Scott,
Scott Dorman wrote:
Why do you need to write to this key any time other than at install time?
Sorry can't talk about it, but I must add a key into this folder. What are the Win32 API functions to change the permissions? André
'A programmer is just a tool which converts caffeine into code'
You can try these articles for more information: http://blogs.msdn.com/asanto/archive/2006/01/22/516009.aspx[^] http://www.thescripts.com/forum/thread259111.html[^] However, you are still probably better off doing this the "right" way and either doing this only at install time, or write the application following the Vista security rules (using application manifests, etc.) If you must do this, you will need to either run the application with admin privileges or launch a separate elevated process (application) that manipulates this key in response to the user clicking a button, etc. that will prompt for credentials. You might also be able to get around this by running in XP Compatability mode, but that's just a workaround.
Scott.
—In just two days, tomorrow will be yesterday. —Hey, hey, hey. Don't be mean. We don't have to be mean because, remember, no matter where you go, there you are. - Buckaroo Banzai [Forum Guidelines] [Articles] [Blog]<</div>