WiX doesn't remove registrykey on uninstall

11,698

The Windows Installer reference counts Components by their Component/@Guid. If you have a Component shared (i.e. Components that have the same @Guid) across MSI files then the contents of the Component will only be removed when both MSIs are uninstalled.

I highly recommend reading about the Component Rules. They control all of this: https://robmensching.com/blog/posts/2003/10/18/component-rules-101

Share:
11,698

Related videos on Youtube

Simon
Author by

Simon

Updated on June 04, 2022

Comments

  • Simon
    Simon almost 2 years

    I've created an Component with an Condition DISABLEMSIUPGRADE, which get's set when I install the MSI using our ExternalUI. However, MSI doesn't remove the entry on UnInstall. I think the problem is caused by the Condition, but I can't fix it.

    <Component Id="compMSI" Guid="5f18af6a-b839-4b4d-9d4f-79cf7826f749">
      <Condition>DISABLEMSIUPGRADE</Condition>
    
      <RegistryKey Root="HKLM" Key="SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\$(var.PGuid)" Action="createAndRemoveOnUninstall">
        <RegistryValue Name="DisplayName" Type="string" Value="$(var.ProductTitle)" />
        <!-- ... -->
      </RegistryKey>
    </Component>
    

    I even placed RemoveRegistryKey Elements in other components to ensure the keys gets removed, but that also didnt do the job...

    I also tried to store and read DISABLEMSIUPGRADE property in the Key.

    //edit: I've experimented a bit and found out, that the CONDITION Element isn't the cause. I looks like if I have another version of my setup installed, the registry key doesn't get removed. What could cause that?

  • Simon
    Simon almost 14 years
    Thank you very much, it works like a charm now ;). However, after reading your blog post, I thought if it's recommended to always use a * as a component guid?
  • Rob Mensching
    Rob Mensching almost 14 years
    When possible, I recommend using the Component/@Guid="*". The WiX toolset will tell you when you can't.
  • Rob Mensching
    Rob Mensching over 13 years
    If you have a Component (remember Components are identified by their @Guid outside of the MSI file) shared across Products then the Component will only be removed when the last MSI uninstalls. Again, the Component Rules blog entry I linked above explains why. Finally, a verbose log file will show you the install state for all your Components.
  • Tam Bui
    Tam Bui about 2 years
    For anyone else not able to get the link working (i.e. page not found), I found out through trial and error that the URL given by Rob is case sensitive. Try this and it will work: robmensching.com/blog/posts/2003/10/18/component-rules-101