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. C#
  4. registry permissions

registry permissions

Scheduled Pinned Locked Moved C#
csharpwindows-adminquestion
5 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.
  • E Offline
    E Offline
    elena12345
    wrote on last edited by
    #1

    A Windows user with regular "user" permissions is running my C# program, and it's not able to access HKEY_LOCAL_MACHINE/Software/Blah Does that sound right? What are the permissions rules for HKEY_LOCAL_MACHINE? Thanks, Elena

    H 2 Replies Last reply
    0
    • E elena12345

      A Windows user with regular "user" permissions is running my C# program, and it's not able to access HKEY_LOCAL_MACHINE/Software/Blah Does that sound right? What are the permissions rules for HKEY_LOCAL_MACHINE? Thanks, Elena

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      By default, everyone has permissions to read HKLM, and that's the way it should be. Users should only be able to write changes to their hive (HKEY_CURRENT_USER). If you have user-specific settings, that's where they should go. Actually for .NET applications, nothing should go in the registry in a typical scenario. You typically use the .config file for application settings. If you have user settings, you can save them in a user's isolated storage (see the System.IO.IsolatedStorage namespace in the .NET Framework SDK). This allows for touchless deployment, or XCOPY deployment as it's sometimes called. At the very least, your application should be sensitive to the fact that settings in the registry might not exist, using default values or displaying user-friendly errors where appropriate.

      Microsoft MVP, Visual C# My Articles

      E 1 Reply Last reply
      0
      • E elena12345

        A Windows user with regular "user" permissions is running my C# program, and it's not able to access HKEY_LOCAL_MACHINE/Software/Blah Does that sound right? What are the permissions rules for HKEY_LOCAL_MACHINE? Thanks, Elena

        H Offline
        H Offline
        Heath Stewart
        wrote on last edited by
        #3

        Oh, and one more thing: depending on the source of the executing app, code access security may be preventing calls as well. If the application is running from the Intranet zone, it's granted limited permissions (no registry access at all). For the Internet zone, either no permissions are granted (.NET 1.0) or very few are granted (.NET 1.1).

        Microsoft MVP, Visual C# My Articles

        1 Reply Last reply
        0
        • H Heath Stewart

          By default, everyone has permissions to read HKLM, and that's the way it should be. Users should only be able to write changes to their hive (HKEY_CURRENT_USER). If you have user-specific settings, that's where they should go. Actually for .NET applications, nothing should go in the registry in a typical scenario. You typically use the .config file for application settings. If you have user settings, you can save them in a user's isolated storage (see the System.IO.IsolatedStorage namespace in the .NET Framework SDK). This allows for touchless deployment, or XCOPY deployment as it's sometimes called. At the very least, your application should be sensitive to the fact that settings in the registry might not exist, using default values or displaying user-friendly errors where appropriate.

          Microsoft MVP, Visual C# My Articles

          E Offline
          E Offline
          elena12345
          wrote on last edited by
          #4

          I am trying to read HKLM, and it's not letting me. Elena

          H 1 Reply Last reply
          0
          • E elena12345

            I am trying to read HKLM, and it's not letting me. Elena

            H Offline
            H Offline
            Heath Stewart
            wrote on last edited by
            #5

            If you're getting a specific problem, be specific. What exception is being thrown? If you're handling the exception, then break into your debugger and tell us. "it's not letting me" tells me nothing. Also, see my other post. If this code is not running from the local machine (or the CAS user policy is more limited), code access security may be preventing the call to the registry class methods. Finally, I told you what the default permissions are. If you want to know what they are on your machine, then open regedit.exe, right-click on HKEY_LOCAL_MACHINE and select Permissions (if you don't see that, use regedt32.exe instead since this was a new UI feature in recent Windows OSes).

            Microsoft MVP, Visual C# My Articles

            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