Zoltan Hernyak
Zoltan Hernyak

Reputation: 1239

WiX Uninstall does not uninstall anything

I am new at using WiX, I created a simple perUser application install with some files, some registry keys, and a file association. I put everything into components with UIDs. Install process works very well.

I read a lot how to define what and how uninstall these, but everywhere it is written that the uninstall process will find every components (files, registry keys, etc) and will deletes them automatically. Instead - after a "successfull" uninstall I can find each file, each registry key untouched. I want everything to be deleted (files, registry keys, file association).

What am I doing wrong?

<?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">

  <!-- DO NOT MODIFY THESE SETTINGS -->
  <?define Manufacturer="MyCompany" ?>
  <?define UpgradeCode="C9998877-7796-4E81-B45B-E7068A15E229" ?>
  <?define VersionNumber="3.3.2"?>
  <?define ProductName="MyCompany Release dosomething" ?>
  <?define ApplicationName="MyCompany Release dosomething App" ?>
  <?define Description="MyCompany Release dosomething Tool" ?>

  <!-- MODIFY THESE SETTINGS AT EVERY NEW VERSION -->
  <?define dosomething_exe_src = "FILES\MyCompanyDoSomething.exe" ?>
  <?define dosomething_ini_src = "FILES\MyCompanyDoSomething.exe.config" ?>
  <?define dosomething_eula_src = "FILES\eula.rtf" ?>


  <Product Id="*"
            Name="$(var.ProductName)"
            Language="1033"
            Version="$(var.VersionNumber)"
            Manufacturer="$(var.Manufacturer)"
            UpgradeCode="$(var.UpgradeCode)">
    <Package Id="*"
             InstallerVersion="200"
             Compressed="yes"
             InstallScope="perUser"
             Manufacturer="$(var.Manufacturer)"
             Description="$(var.Description)"
            InstallPrivileges="limited" />
    <Media Id="1" Cabinet="media1.cab" EmbedCab="yes" />

    <Property Id="ALLUSERS" Secure="yes" />




    <Upgrade Id="$(var.UpgradeCode)">
      <UpgradeVersion Minimum="$(var.VersionNumber)" IncludeMinimum="no"
                      OnlyDetect="yes"
                      Property="NEWERVERSIONS" />
      <UpgradeVersion Minimum="0.0.0" IncludeMinimum="yes"
                      Maximum="$(var.VersionNumber)" IncludeMaximum="no"
                      OnlyDetect="no"
                      IgnoreRemoveFailure="yes"
                      Property="OLDERVERSIONS" />
    </Upgrade>

    <Condition Message="A newer version of [ProductName] is already installed. Exiting installation.">
      <![CDATA[Installed OR NOT NEWERVERSIONS]]>
    </Condition>

    <Condition Message="!(loc.LaunchCondition_AllUsers)">
      NOT ALLUSERS
    </Condition>

    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Installation Variables                                                                      :: -->
    <Property Id="WixAppFolder" Value="WixPerUserFolder" />
    <Property Id="ApplicationFolderName" Value="Install path" />
    <Property Id="WIXUI_INSTALLDIR" Value="APPLICATIONFOLDER"/>
    <WixVariable Id="WixUILicenseRtf" Value="FILES\eula.rtf" />


    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Main Installation Directory Structure                                                       :: -->

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="LocalAppDataFolder">
        <!-- perUser case, it is redirected automatically to LocalAppDataFolder -->
        <Directory Id="ProgramFilesHK" Name="$(var.Manufacturer)">
          <Directory Id="APPLICATIONFOLDER" Name="$(var.ApplicationName)">
            <Component Id="CMP_dosomething_exe" Guid="0BA6F4AB-9ED4-4CF2-BDFF-0C95F1DF4BA0" Permanent="no">
              <CreateFolder />
              <RemoveFolder Id="RemoveFolder_ProgramFilesHK" Directory="ProgramFilesHK" On="uninstall" />
              <RemoveFolder Id="RemoveFolder_ApplicationFolder" Directory="APPLICATIONFOLDER" On="uninstall" />

              <File Source="$(var.dosomething_exe_src)" Id="dosomething_exe_file" Vital="yes" />

              <ProgId Id="$(var.ApplicationName).Document" Description="$(var.Description)" Advertise="no">
                <Extension Id="MyCompanyDoSomething" ContentType="application/MyCompanyDoSomething">
                  <Verb Id="Open" Command="Open" Argument="&quot;%1&quot;" TargetFile="dosomething_exe_file"/>
                  <MIME Advertise="no" ContentType="application/MyCompanyDoSomething" Default="yes" />
                </Extension>
              </ProgId>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
            <Component Id="CMP_dosomething_ini" Guid="6F0201F1-A1C1-4378-9ED7-5D47AB750AD1">
              <File Source="$(var.dosomething_ini_src)" Id="dosomething_ini_file" Vital="yes"/>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
            <Component Id="CMP_eula_doc" Guid="{9D320C1F-E16A-46D3-AF2F-5AE496B8C365}">
              <File Source="$(var.dosomething_eula_src)" Id="dosomething_eula_file" Vital="yes"/>
              <RegistryKey Root="HKCU" Key="Software\MyCompany\MyApplication" ForceDeleteOnUninstall="yes">
                <RegistryValue Name="Version" Value="[ProductVersion]" Type="string" KeyPath="yes"/>
              </RegistryKey>
            </Component>
          </Directory>
        </Directory>
      </Directory>

      <Directory Id="DesktopFolder">
      </Directory>

      <Directory Id="ProgramMenuFolder">
        <Directory Id="AppShortcutsDir" Name="$(var.ApplicationName)" />
      </Directory>
    </Directory>


    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Desktop -> Shortcut to start the application                                                :: -->
    <DirectoryRef Id="DesktopFolder">
      <Component Id="CMP_DesktopShortcut" Guid="{E6024E33-E5B8-4136-9402-22BA0614013D}">
        <Shortcut Id="DAppStarterShortcut" Name="$(var.ApplicationName)" Description="$(var.Description)" Target="[APPLICATIONFOLDER]MyCompanyDoSomething.exe" />
        <RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>

    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Start Menu -> Shortcuts to start the application, eula, uninstall, etc.                     :: -->
    <DirectoryRef Id="AppShortcutsDir">
      <Component Id="CMP_StartMenuShortcut" Guid="{439DAE58-5DE5-4A45-952E-05956D5B4A49}">
        <Shortcut Id="SAppStarterShortcut" Name="$(var.ApplicationName)" Description="$(var.Description)" Target="[APPLICATIONFOLDER]MyCompanyDoSomething.exe" />
        <Shortcut Id="SEulaReadShortcut" Name="$(var.ApplicationName) EULA" Description="End User Agreement" Target="[APPLICATIONFOLDER]eula.rtf" />
        <Shortcut Id="SUninstallShortcut" Name="Uninstall $(var.ApplicationName)" Description="Uninstall $(var.ApplicationName) and all of its components" Target="[SystemFolder]msiexec.exe" Arguments="/x [ProductCode]" />
        <RemoveFolder Id="RemoveMyShortcutsDir" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\$(var.Manufacturer)\$(var.ProductName)" Name="installed" Type="integer" Value="1" KeyPath="yes" />
      </Component>
    </DirectoryRef>




    <!-- ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -->
    <!-- :: Installation Feature Tree                                                                    :: -->
    <Feature Id="MyCompanyDosomethingTool" Title="MyCompany Dsomething Tool" Level="1" ConfigurableDirectory="APPLICATIONFOLDER">
      <ComponentRef Id="CMP_dosomething_exe" />
      <ComponentRef Id="CMP_dosomething_ini" />
      <ComponentRef Id="CMP_eula_doc" />
      <ComponentRef Id="CMP_StartMenuShortcut" />
      <ComponentRef Id="CMP_DesktopShortcut" />
    </Feature>

    <InstallExecuteSequence>
      <RemoveExistingProducts After="InstallInitialize" />
      <InstallExecute After="RemoveExistingProducts" />
    </InstallExecuteSequence>

    <UIRef Id="WixUI_Mondo" />
  </Product>
</Wix>

Upvotes: 0

Views: 250

Answers (1)

MOS
MOS

Reputation: 137

On the component elements you can add the: RemoveFile, RemoveFolder, RemoveRegistryKey and RemoveRegistryValue elements. See http://wixtoolset.org/documentation/manual/v3/xsd/wix/component.html

Example (for folder and key):

<Directory Id="ProgramMenuFolder" Name="Programs">
    <Directory Id="ProgramMenuDir" Name="AppName $(var.Version)">
      <Component Id="ProgramMenuDir" Guid="*">
        <RemoveFolder Id='ProgramMenuDir' On='uninstall' />
        <RegistryValue id= Root='HKCU' Key='Software\[Manufacturer]\[ProductName]' Type='string' Value='' KeyPath='yes' />
        <RemoveRegistryKey Id='RegCleanup' Root='HKCU' Action='removeOnInstall' Key='Software\[Manufacturer]\[ProductName]'/>
      </Component>
    </Directory>
</Directory>

You can omit the Directory attribute if you don't wan't to override the parent component directory.

As far as I understand the Id of the RemoveFolder component should match the Id of the directory you which to remove (this works for me).

In your case this would translate into something like this:

<Directory Id="LocalAppDataFolder">
<!-- perUser case, it is redirected automatically to LocalAppDataFolder -->
    <Directory Id="ProgramFilesHK" Name="$(var.Manufacturer)">
      <Directory Id="APPLICATIONFOLDER" Name="$(var.ApplicationName)">
        <Component Id="CMP_dosomething_exe" Guid="0BA6F4AB-9ED4-4CF2-BDFF-0C95F1DF4BA0" Permanent="no">
          <CreateFolder />
          <RemoveFolder Id="ProgramFilesHK" On="uninstall" />
          <RemoveFolder Id="APPLICATIONFOLDER" On="uninstall" />
            [removed stuff]
        </Component>
      </Directory>
    </Directory>
</Directory>

Upvotes: 1

Related Questions