Search code examples
wixwindows-installerregistry

Registry entry not working correctly in Wix


I am creating an x64 msi. I have some registry values to set. In Wix I am using the following code.

  <Component Id="RegistryEntries1" Guid="{GUID1}" Win64="yes">
    <RegistryKey Root="HKLM"
                 Key="Software\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{FF.....}"
                 Action="createAndRemoveOnUninstall">
      <RegistryValue Type="string" Value="SomeName" KeyPath="yes"/>
    </RegistryKey>
  </Component>


  <Component Id="RegistryEntries2" Guid="{GUID2}" Win64="yes">
    <RegistryKey Root="HKCR"
                   Key="CLSID\{FF.....}"
                   Action="createAndRemoveOnUninstall">
      <RegistryValue Type="string" Value="SomeName" KeyPath="yes"/>
    </RegistryKey>
  </Component>


  <Component Id="RegistryEntries3" Guid="{GUID3}" Win64="yes">
    <RegistryKey Root="HKCR"
                   Key="CLSID\{{FF.....}\InprocServer32"
                   Action="createAndRemoveOnUninstall">
      <RegistryValue Type="string" Value="SomeName.dll" KeyPath="no"/>
      <RegistryValue Type="string" Name="ThreadingModel" Value="Apartment" KeyPath="yes"/>
    </RegistryKey>
  </Component>

The values are set in registry, but my application does not work correctly.

When I set the registry values using a reg file, the application working properly.

And my SomeName.dll is in System32

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\Credential Providers\{FF.....}]
@="SomeName"

[HKEY_CLASSES_ROOT\CLSID\{FF.....}]
@="SomeName"

[HKEY_CLASSES_ROOT\CLSID\{FF.....}\InprocServer32]
@="SomeName.dll"
"ThreadingModel"="Apartment"

Is there any problem in my Wix code.


Solution

  • The issue is likely to be that HKCR is a virtual key, in your case a merge view of HKLM\Software\Classes and HKCU\Software\Classes. This explains it:

    https://msdn.microsoft.com/en-us/library/windows/desktop/ms724475(v=vs.85).aspx

    so something running with the local system account sees neither of these. If you were to run regedit with the system account you wouldn't see your HKCR classes if this is what's happening.

    So if you do the entries at HKLM\Software\Classes I think your service/service installer code would see them. ServiceInstaller classes often run as custom actions with the system account. If you're using WiX you don't need ServiceInstaller classes (maybe you migrated from Visual Studio setups) because ServiceInstall and ServiceControl will do the job.