9

I have an WIX installer. I try to add a registry key depending on the installation path (VS Installer easy) in this case thought it would be a piece of cake ... This is my XML for WIX:

<Feature Id="ProductFeature" Title="ChessBarInfoSetup" Level="1">
        <!--<ComponentGroupRef Id="ProductComponents" />-->
  <ComponentRef Id='InstallRegistryComponent' />
  <ComponentRef Id='ProductComponent' />
    </Feature>
</Product>

<Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
        <Directory Id="ProgramFilesFolder">
    <Directory Id="ManufacturerFolder" Name="$(var.manufacturer)">
      <Directory Id="INSTALLFOLDER" Name="$(var.productName)">

        <!--<ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">-->
          <Component Id="InstallRegistryComponent" Guid="*">
            <RegistryKey Id='ChessInfoBarInstallDir' Root='HKLM' Key='Software\[Manufacturer]\[ProductName]' Action='createAndRemoveOnUninstall'>
              <RegistryValue Type='string' Name='InstallDir' Value="[INSTALLDIR]" Action="write" KeyPath="yes" />
              <!--<RegistryValue Type='integer' Name='Flag' Value='0'/>-->
            </RegistryKey>
          </Component>
          <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
          <Component Id="ProductComponent" Guid="*">
            <File Source="$(var.ChessInfoTaskBar.TargetPath)" />
          </Component>
        <!--</ComponentGroup>-->

      </Directory>
    </Directory>
        </Directory> 
</Directory>
</Fragment>

The value is created but is always an empty string. Tried it with INSTALLLOCATION and others... What am I doing wrong (saw the Value=[INSTALLDIR] on a wix tutorial page)?

2
  • Probably a stupid question - but what is requiring you to add the installation directory into the registry? Commented Nov 18, 2012 at 19:44
  • Damien, for example. Example to use it. Commented Apr 17, 2013 at 12:26

1 Answer 1

11

It is empty because you are using INSTALLDIR instead of INSTALLFOLDER

<Directory Id="INSTALLFOLDER" Name="$(var.productName)">

<RegistryValue Type='string' Name='InstallDir' Value="[INSTALLFOLDER]" />

That should give you the installation directory.

Sign up to request clarification or add additional context in comments.

2 Comments

... I have could sworn that I have used this option ... well THX
In my case, I've misspelled "INSTALLLDIR" (three "L"s instead of two). After changing it, I was able to use "INSTALLDIR".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.