Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. How to change registry key permissons from a C#

How to change registry key permissons from a C#

Scheduled Pinned Locked Moved .NET (Core and Framework)
questioncsharpwindows-admintutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Andre Ziegler
    wrote on last edited by
    #1

    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'

    S 1 Reply Last reply
    0
    • A Andre Ziegler

      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'

      S Offline
      S Offline
      Scott Dorman
      wrote on last edited by
      #2

      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]

      A 1 Reply Last reply
      0
      • S Scott Dorman

        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]

        A Offline
        A Offline
        Andre Ziegler
        wrote on last edited by
        #3

        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'

        S 1 Reply Last reply
        0
        • A Andre Ziegler

          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'

          S Offline
          S Offline
          Scott Dorman
          wrote on last edited by
          #4

          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>

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups