Search code examples
wixregistryrelative-path

How to set a WiX RegistryValue relative to the install path


This leaves me with \Default.udl

<RegistryKey Key="Software\My Company\Product\Connections" Root="HKCU">
  <RegistryValue Name="Default" Value="[INSTALLLOCATION]\Default.udl" Type="string" />
</RegistryKey>

I'd like something like C:\Program Files\Company\Product\Default.udl


Solution

  • I can think of a few things that could be causing the issue.

    Are you sure your directory layout is correct? It should look something like this:

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="CompanyFolder" Name="My Company">
          <Directory Id="INSTALLLOCATION" Name="Product">
          </Directory>
        </Directory>
      </Directory>
    </Directory>
    

    I believe the HKCU hive is meant to be used only in a per-user install, but the path you specified is under Program Files. You might want to take a look at the Installation Context documentation for the differences between per-user and per-machine installs. In some versions of Windows, ProgramFilesFolder has a different value in per-user mode.

    Alternatively, if your installer is laying down the Default.udl file, you could use the [#filekey] syntax to point directly to that file.

    <RegistryValue Name="Default" Value="[#Default.udl]" Type="string" />