none
Windows Installer on Windows 7 access the HKEY_LOCAL_MACHINE registry

    Question

  • I am using Windows Installer to modify the HKEY_LOCAL_MACHINE hive [specifically HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Run entry]. 

    It works fine for Windows XP and below, but with Windows 7 it cannot write the registery value.   I have temporarily changed HKEY_LOCAL_MACHINE  to HKEY_CURRENT_USER, but I would like to get it running properly.

    I had the same problem with the program that Windows Installer installs, until I modified the manifest file to give my program access to HKEY_LOCAL_MAHCINE on Windows 7.

    Now I need to give Windows Installer the same access to HKEY_LOCAL_MACHINE on Windows 7.

    I am using Visual Studio 2008.   I need a programatical way to solve this problem.   This install program will be distributed to users and I cannot require them to go through a complicated series of steps setting the installer as "Run as administrator," and so forth.

    This install program needs to run on its own correctly without any series of steps run by the user other than launching it.

    • Moved by Brittany Behrens Wednesday, July 07, 2010 10:08 PM Application deployment issue (From:Visual Studio Editor)
    Tuesday, July 06, 2010 8:10 PM

Answers

  • Hi,

     

    How did you create register enter for your application? Visual Studio offers an easy way to do this. Please look at the following screen shot.

     

    Visual Studio add register enter function.

     

    screen shot

     

    After you install the application, you can find the enter in regedit. Mine is x64 OS so it locates in Wow6432Node.

     

    screen shot

     

    Do you use x64 OS? Does the register editor function in VS setup project work?

     

    Sincerely,

    Kira Qian

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by Kira Qian Friday, July 09, 2010 2:55 AM
    Thursday, July 08, 2010 3:31 AM
  • You may need to supply a bit more information.  Some of what you're saying is confusing.

    1. As Kira asked, is this an x64 OS?

    2. Is your setup built for an x64 or x86 platform? Note that Kira's example shows an x86 install where the registry item is created in the Wow6432 node. If you look in the 64-bit native registry view you will not see your key.

    3. Programs have manifest files, MSI files do not.

    4. If you create the entries the way Kia describes it just works. Nothing about this has changed on Windows 7 because you have always needed to be an administrator to update HKLM entries. Your installing users still need to be administrators, XP was the same.


    Phil Wilson
    • Marked as answer by Kira Qian Friday, July 09, 2010 2:56 AM
    Thursday, July 08, 2010 7:21 PM

All replies

  • Hi,

     

    How did you create register enter for your application? Visual Studio offers an easy way to do this. Please look at the following screen shot.

     

    Visual Studio add register enter function.

     

    screen shot

     

    After you install the application, you can find the enter in regedit. Mine is x64 OS so it locates in Wow6432Node.

     

    screen shot

     

    Do you use x64 OS? Does the register editor function in VS setup project work?

     

    Sincerely,

    Kira Qian

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    • Marked as answer by Kira Qian Friday, July 09, 2010 2:55 AM
    Thursday, July 08, 2010 3:31 AM
  • I created the registry entry the way you suggest.    [HKEY_LOCAL_MACHINE].

    But in Windows 7, the registry key is NOT created when the installer program runs, so I changed it to HKEY_CURRENT_USER.

    Try a simple installer example.   HKEY_LOCAL_MACHINE is protected.   For my program I had to modify the manifest file and change the UAC Execution level to requireAdministrator.

    But there is now way to do that for an installer, that I know of.

    Thursday, July 08, 2010 4:58 PM
  • You may need to supply a bit more information.  Some of what you're saying is confusing.

    1. As Kira asked, is this an x64 OS?

    2. Is your setup built for an x64 or x86 platform? Note that Kira's example shows an x86 install where the registry item is created in the Wow6432 node. If you look in the 64-bit native registry view you will not see your key.

    3. Programs have manifest files, MSI files do not.

    4. If you create the entries the way Kia describes it just works. Nothing about this has changed on Windows 7 because you have always needed to be an administrator to update HKLM entries. Your installing users still need to be administrators, XP was the same.


    Phil Wilson
    • Marked as answer by Kira Qian Friday, July 09, 2010 2:56 AM
    Thursday, July 08, 2010 7:21 PM
  • Ok, for some reason now I got it to work.

    Thanks.

    Thursday, July 08, 2010 11:30 PM
  • I'm having this same problem too. My install kits work fine under Windows XP but they won't write the registry keys in [HKEY_LOCAL_MACHINE] in the folder that I specify. I'm running Windows 7 Enterprise 64 bit, using VS 2008 and the install kits are made with VS 2008. It still won't write to the registry even if I install locally as an administrator. The install kits are MSI files. The setups are built for an x86 platform..
    Friday, July 16, 2010 3:03 PM
  • I made a sample installer that did nothing but write to HKEY_LOCAL_MACHINE and then tested it on both XP and Win 7.  It worked.   After that I tested the old installer and it wrote to HKEY_LOCAL_MACHINE.

    Your installer (.msi file) should pop up a UAC dialog.   When you repsond yes to the dialog, that allows the installer (.msi) to write to the registry in HKEY_LOCAL_MACHINE.

    Friday, July 16, 2010 3:32 PM
  • I made a sample installer that did nothing but write to HKEY_LOCAL_MACHINE and then tested it on both XP and Win 7.  It worked.   After that I tested the old installer and it wrote to HKEY_LOCAL_MACHINE.

    Your installer (.msi file) should pop up a UAC dialog.   When you repsond yes to the dialog, that allows the installer (.msi) to write to the registry in HKEY_LOCAL_MACHINE.


    I tried that and it didn't work. I have the permissions set on the key so that administrators local and from the network can write to the key that I need too. I did notice that HKEY_LOCAL_MACHINE didn't have permissions for network admins. I wonder if that would have anything to do with it?

     

    It writes fine to HKEY_CURRENT_USER btw...

    Friday, July 16, 2010 4:49 PM
  • Yes, HKEY_CURRENT_USER works find.   There is an extra layer of security for HKEY_LOCAL_MACHINE.

    I can send you the sample installer I wrote that works on Windows 7, if you like.

    Friday, July 16, 2010 5:08 PM
  • I created a setup project in VS 2008 and had it just write to the registry key under HKEY_LOCAL_MACHINE. It just won't write the key. No errors or messages other than the dialog box that asks for path and if I want to install it for all users or just me.

    What did you do that was different?

    BTW, I can import reg keys into HKEY_LOCAL_MACHINE just fine too..

    Friday, July 16, 2010 5:19 PM
  • I create a setup project in VS 2008 and added a key to HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Run.

    I added the string: String = "Value".

    That's it.

    Friday, July 16, 2010 5:44 PM
  • Ok, I tried that and it didn't work. I also tried creating that key manually through regedit and it still didn't work. I think the network team has my pc locked down to much. I can't even run the installer as an administrator by right clicking on it to get that option. It doesn't exist. However; I am an administrator on my pc, so I don't get it.. I've tried having them figure this out too and they seemed to be at a loss why its not working.  I may just say the heck with it and start using INI or XML files for settings...

     

    Friday, July 16, 2010 6:52 PM
  • Ok, you've got something here.   If it doesn't work manually, it won't work programatically.    The technique I described will work only if it also works manually.   You've probably got some persmission issues.
    Friday, July 16, 2010 7:16 PM