Search code examples
wixwix3.5wix3wix3.7wix3.6

Can we use KeyPath="no" with the "Component" element along with the Registry


I have generated windows installer package (.msi file) for my project.

I installed the installer but after that I am unable to launch the application.

So, I am going through the .wxs files to find the root cause and find some suspecious code

<Wix xmlns="http://wixtoolset.org/schemas/v4/wxs">
  <Fragment>
    <DirectoryRef Id="INSTALLDIR">

      <!-- This component creates EMR v3.0 Registry Entries-->

      <Component Id="RegistryEntries_Set1" Guid="1A20601C-77EA-11E0-98C2-1AD64824019B" KeyPath="no">
        <!-- To remove stray registry entries under HKLM,HKU and HKCU registry hives-->
        <!--<Registry Id="Delete$(var.CompanyName)Node" Root="HKLM" Key="Software\$(var.CompanyName)\$(var.ProductName)" Action="removeKeyOnUninstall" />-->
        <RegistryKey Id="Delete$(var.CompanyName)Node" Root="HKLM" Key="Software\$(var.CompanyName)\$(var.ProductName)" Action="createAndRemoveOnUninstall" />
        <RegistryKey Id="Delete$(var.CompanyName)Node2" Root="HKU" Key=".DEFAULT\Software\$(var.CompanyName)" Action="createAndRemoveOnUninstall" />
        <RegistryKey Id="Delete$(var.CompanyName)Node3" Root="HKCU" Key="Software\$(var.CompanyName)" Action="createAndRemoveOnUninstall" />

I understood that if the Keypath = "yes" means, windows installer treats that the keypath resource is present and it won't install it again.

And if Keypath = "no", it will install.

Here in this context i want to know what is meant by KeyPath="no" and also want to understand this code snippet?

What the Component will do here?


Solution

  • From the Wix documentation, if the KeyPath value is not set to 'yes' in a component, it will automatically try to select one of the elements declared inside of the component as a KeyPath.

    So in what you are showing in your example, the first RegistryKey element of your Component will be declared as a KeyPath. Your code sample will create 3 registry keys upon installation (and will remove them when you uninstall it) and will consider that the component is installed if the registry key that has automatically been selected as a KeyPath is present on the system.