Installer. Set registry key permissions

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vavc1980
    New Member
    • Feb 2008
    • 25

    Installer. Set registry key permissions

    I coded a windows service in Visual Studio 2005, I have the installer with it.
    The registry keys for the service are created in System\controls et001\MyService .
    The service is installed with LocalService account.

    Problem is, after installing it, my service tries to add a key into that registry key location (intentionally added in the code), and it always fails because it does not have permissions, so I have to manually open the registry key and set permissions to LocalService, and start the service again.

    Is there any way to set the permissions in the registry key at the installation process of the service?
  • tlhintoq
    Recognized Expert Specialist
    • Mar 2008
    • 3532

    #2
    The registry keys for the service are created in System\controls et001\MyService .
    Which hive are you trying to do this in?
    Personlly, I don't thing it should be in ...\System\ ... anything
    The hives are organized with a subsection for Software. Generally by company name

    HKEY_CURRENT_US ER\SOFTWARE\MyC ompanyName\MyPr ogramName

    Is the accepted standard.

    Comment

    • vavc1980
      New Member
      • Feb 2008
      • 25

      #3
      It is in HKEY_LOCAL_MACH INE\SYSTEM\...

      Thanks for the info. I did not know about the standard.
      I did not specify that anywhere, that is where the installer created it.

      Where can I specify that?
      how about my original question about setting the permissions for the LocalService user when installing? do you have a suggestion?

      Thanks.

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        did not specify that anywhere
        Problem is, after installing it, my service tries to add a key into that registry key location
        I don't understand. Your program is trying to write a registry key, but you aren't specifying where? How can that be?

        If you aren't saying where to write it, then how are (do you expect) to read it back?

        Comment

        • vavc1980
          New Member
          • Feb 2008
          • 25

          #5
          Sorry I was not clear before.

          When I install the service, it creates that path in the registry (with the description, displayname, errorcontrol, and other keys) in the location I told you before.

          Of course in my code I'm using that path to create/read a key that I use for other purposes.
          My original problem is that everytime I install the service that registry path does not have permissions for LocalService, thus my custom key cannot be created and I get an error. I need to open the registry manually and give the permissions then re-start the service and everything works fine.

          Then you told me that the standard is to have the keys in HKEY_CURRENT_US ER\SOFTWARE\MyC ompanyName\MyPr ogram Name,
          how can I specify that in the installer so when I install the service it creates all the keys in that path?, I obviously would update my code to write/read my custom key from that location.

          I hope it is clear this time.

          Thanks.

          Comment

          • Plater
            Recognized Expert Expert
            • Apr 2007
            • 7872

            #6
            I see what you are saying.
            I believe the key you are trying to access is the key subset that tells windows the program is a service (and various other settings required to deal with it)
            I think you will want your installer to install an additional key set in the standard location that tlhintoq pointed out. Then you should have the permissions for that keyset

            Comment

            • vavc1980
              New Member
              • Feb 2008
              • 25

              #7
              Thanks Plater and tlhintoq for your suggestions.

              I did what you guys suggested, in my installer project I went to the Registry section (right click on the project -> View -> Registry) and added my key in HKEY_CURRENT_US ER\SOFTWARE\MyC ompanyName\MyPr ogramName.

              Obviously I updated my code to read/write the value needed at that key. I seems like it works now without having to set the permission to Local_Service.
              I'll be moving my project to QA soon, hopefully it'll work.

              Thanks again!.

              Comment

              Working...