title: Remove existing product and install it again.guide me with example code
body: <p>I want to add feature if setup run second time it will remove existing product first. without version feature. kindly guide me how i make sure if product already exist. setup will remove it first and install it again and after installation launch application.
  OR
  if product with same version already exist setup launch the Application.
  its good if having sample code please share that too. Thanks advance.</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;Wix xmlns="http://schemas.microsoft.com/wix/2006/wi"&gt;
    &lt;?define EmbeddApp_TargetDir=$(var.EmbeddApp.TargetDir)?&gt;
    &lt;Product Id="*" Name="Troytec_TestEngine" Language="1033" Version="1.0.0.0" Manufacturer="TroyTec" UpgradeCode="c28ad43a-4fe4-4d14-ba4f-6422c00b13c2"&gt;
      &lt;Package Id="*" InstallerVersion="200" Compressed="yes" InstallScope="perMachine" /&gt;
  
      &lt;!--&lt;MajorUpgrade AllowDowngrades="yes" /&gt;--&gt;
      &lt;MediaTemplate /&gt;
  
      &lt;Property Id="PREVIOUSVERSIONSINSTALLED" Secure="yes" /&gt;
  &lt;Upgrade Id="a61287ef-e184-421b-ac76-d8b91e489a6d"&gt;  
     &lt;UpgradeVersion
        Minimum="1.0.0.0" Maximum="99.0.0.0"
        Property="PREVIOUSVERSIONSINSTALLED"
        IncludeMinimum="yes" IncludeMaximum="no" /&gt;
  &lt;/Upgrade&gt;
  
      &lt;Feature Id="ProductFeature" Title="Troytec_TestEngine" Level="1"&gt;
        &lt;ComponentGroupRef Id="ProductComponents" /&gt;
        &lt;ComponentRef Id="ApplicationShortcut" /&gt;
        &lt;ComponentRef Id="ApplicationShortcutDesktop" /&gt;
        &lt;ComponentRef Id="CMP_MyEmptyDir" /&gt;
        &lt;ComponentRef Id="CMP_MyEmptyDir2" /&gt;
        &lt;ComponentRef Id="CMP_MyEmptyDir3" /&gt;
      &lt;/Feature&gt;
  
  
       &lt;!--Step 2: Add UI to your installer / Step 4: Trigger the custom action--&gt; 
      &lt;!--&lt;UI&gt;
        &lt;UIRef Id="WixUI_Minimal" /&gt;
        &lt;Publish Dialog="ExitDialog"
            Control="Finish"
            Event="DoAction"
            Value="LaunchApplication"&gt;WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed&lt;/Publish&gt;
      &lt;/UI&gt;--&gt;
      &lt;Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch My Application Name" /&gt;
  
       &lt;!--Step 3: Include the custom action--&gt; 
      &lt;!--&lt;Property Id="WixShellExecTarget" Value="[EmbeddApp.exe]" /&gt;--&gt;
      &lt;CustomAction Id="LaunchApplication"
          BinaryKey="WixCA"
          DllEntry="WixShellExec"
          Impersonate="yes" /&gt;
  
  
  
  
    &lt;/Product&gt;
    &lt;!--&lt;Fragment&gt;
      &lt;InstallExecuteSequence&gt;
        &lt;Custom Action='902bc339-5cef-4f74-9d04-07941afa8ba1' Before='6d48fcc2-99cb-4ab6-867a-79f0484db05c'&gt;
          (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
        &lt;/Custom&gt;
      &lt;/InstallExecuteSequence&gt;
    &lt;/Fragment&gt;--&gt;
  
  
  
  
  
  
    &lt;Fragment&gt;
      &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
        &lt;Directory Id="ProgramFilesFolder"&gt;
          &lt;Directory Id="INSTALLFOLDER" Name="Troytec_TestEngine" &gt;
            &lt;Directory Id="FOLDER1" Name="GPUCache"&gt;
            &lt;/Directory&gt;
              &lt;Directory Id="FOLDER2" Name="locales"&gt;
                &lt;/Directory&gt;
            &lt;Directory Id="FOLDER3" Name="swiftshader"&gt;
              &lt;/Directory&gt;
        &lt;/Directory&gt;
      &lt;/Directory&gt;
        &lt;Directory Id="ProgramMenuFolder"&gt;
          &lt;Directory Id="ApplicationProgramsFolder" Name="Troytec_TestEngine" /&gt;
        &lt;/Directory&gt;
        &lt;Directory Id="DesktopFolder" Name="Desktop"/&gt;
  
      &lt;/Directory&gt;
    &lt;/Fragment&gt;
  
    &lt;Fragment&gt;
      &lt;Icon Id="City.ico" SourceFile="letter-t-24.ico" /&gt;
      &lt;DirectoryRef Id="ApplicationProgramsFolder"&gt;
        &lt;Component Id="ApplicationShortcut" Guid="9bd13330-6540-406f-a3a8-d7f7c69ae7f9"&gt;
          &lt;Shortcut Id="ApplicationStartMenuShortcut" Name="Troytec_TestEngine" Description="MyWpfApplication" Target="[INSTALLFOLDER]EmbeddApp.exe" WorkingDirectory="INSTALLFOLDER" Icon ="City.ico" /&gt;
          &lt;RemoveFolder Id="RemoveApplicationProgramsFolder" Directory="ApplicationProgramsFolder" On="uninstall" /&gt;
          &lt;RegistryValue Root="HKCU" Key="Software\MyWpfApplication" Name="installed" Type="integer" Value="1" KeyPath="yes" /&gt;
        &lt;/Component&gt;
      &lt;/DirectoryRef&gt;
      &lt;DirectoryRef Id="DesktopFolder"&gt;
        &lt;Component Id="ApplicationShortcutDesktop" Guid="cde1e030-eb64-49a5-b7b8-400b379c2d1a"&gt;
          &lt;Shortcut Id="ApplicationDesktopShortcut" Name="Troytec_TestEngine" Description="MyWpfApplication" Target="[INSTALLFOLDER]EmbeddApp.exe" WorkingDirectory="INSTALLFOLDER" Icon ="City.ico" /&gt;
          &lt;RemoveFolder Id="RemoveDesktopFolder" Directory="DesktopFolder" On="uninstall" /&gt;
          &lt;RegistryValue Root="HKCU" Key="Software\Troytec_TestEngine" Name="installed" Type="integer" Value="1" KeyPath="yes" /&gt;
        &lt;/Component&gt;
      &lt;/DirectoryRef&gt;
    &lt;/Fragment&gt;
  
  
    &lt;Fragment&gt;
  
  
  
  &lt;/Fragment&gt;
  
  
  
  
    &lt;Fragment&gt;
      &lt;ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER"&gt;
        &lt;!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. --&gt;
        &lt;!-- &lt;Component Id="ProductComponent"&gt; --&gt;
        &lt;!-- TODO: Insert files, registry keys, and other resources here. --&gt;
        &lt;!-- &lt;/Component&gt; --&gt;
  
        &lt;Component Id="EmbeddApp.exe" Guid="85c6f764-7517-4bc6-8e5a-ec52ae6ece1e"&gt;
          &lt;File Id="EmbeddApp.exe" Name="EmbeddApp.exe" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.exe" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="EmbeddApp.exe.config" Guid="8ee125d7-7043-498a-ad65-24055252218a"&gt;
          &lt;File Id="EmbeddApp.exe.config" Name="EmbeddApp.exe.config" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.exe.config" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.WinForms.dll" Guid="9fdb1c25-2275-4a14-8f4f-6832b7a617dc"&gt;
          &lt;File Id="CefSharp.WinForms.dll" Name="CefSharp.WinForms.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.dll" Guid="9bdbc9cc-52a6-4213-b941-0248e995aa71"&gt;
          &lt;File Id="CefSharp.dll" Name="CefSharp.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.Core.dll" Guid="0e058c32-f73b-4b3f-acbd-b0c29c019297"&gt;
          &lt;File Id="CefSharp.Core.dll" Name="CefSharp.Core.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.dll" /&gt;
        &lt;/Component&gt;
  
        &lt;!--other files--&gt;
  
        &lt;Component Id="cef.pak" Guid="283c053a-c66e-4889-9c6b-2884b50b8cbb"&gt;
          &lt;File Id="cef.pak" Name="cef.pak" Source="$(var.EmbeddApp_TargetDir)cef.pak" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="cef_100_percent.pak" Guid="12342b21-68e4-4874-ac3f-87ac8a9f40c2"&gt;
          &lt;File Id="cef_100_percent.pak" Name="cef_100_percent.pak" Source="$(var.EmbeddApp_TargetDir)cef_100_percent.pak" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="cef_200_percent.pak" Guid="b261180b-0fa2-41ea-ba8d-63d329f2d047"&gt;
          &lt;File Id="cef_200_percent.pak" Name="cef_200_percent.pak" Source="$(var.EmbeddApp_TargetDir)cef_200_percent.pak" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="cef_extensions.pak" Guid="a4a0a9d0-0308-46be-b24a-7de985018039"&gt;
          &lt;File Id="cef_extensions.pak" Name="cef_extensions.pak" Source="$(var.EmbeddApp_TargetDir)cef_extensions.pak" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.BrowserSubprocess.Core.dll" Guid="f3e2f9bc-066a-43f0-9e14-445d7af00243"&gt;
          &lt;File Id="CefSharp.BrowserSubprocess.Core.dll" Name="CefSharp.BrowserSubprocess.Core.dll" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.Core.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.BrowserSubprocess.Core.pdb" Guid="6127f13d-4b77-4a7f-992d-5b49abb2dfee"&gt;
          &lt;File Id="CefSharp.BrowserSubprocess.Core.pdb" Name="CefSharp.BrowserSubprocess.Core.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.Core.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.BrowserSubprocess.exe" Guid="4b029801-a97e-47a0-8f37-0a0540bed89e"&gt;
          &lt;File Id="CefSharp.BrowserSubprocess.exe" Name="CefSharp.BrowserSubprocess.exe" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.exe" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.BrowserSubprocess.pdb" Guid="d47f6d16-c6f5-4cf3-98a8-a342444e225f"&gt;
          &lt;File Id="CefSharp.BrowserSubprocess.pdb" Name="CefSharp.BrowserSubprocess.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.BrowserSubprocess.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.Core.pdb" Guid="f9ae3c06-3c49-40af-8047-da555d43304b"&gt;
          &lt;File Id="CefSharp.Core.pdb" Name="CefSharp.Core.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.Core.xml" Guid="71e6a1c8-e1c2-4f41-bf09-c664cd62b0a7"&gt;
          &lt;File Id="CefSharp.Core.xml" Name="CefSharp.Core.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.Core.xml" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.pdb" Guid="1f6df66a-972c-4945-a675-ab7f6bff3207"&gt;
          &lt;File Id="CefSharp.pdb" Name="CefSharp.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.WinForms.pdb" Guid="9f9aa753-8be7-4349-bf90-3799c9cb8560"&gt;
          &lt;File Id="CefSharp.WinForms.pdb" Name="CefSharp.WinForms.pdb" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.WinForms.xml" Guid="56dc62fa-e64e-4f92-a8df-3415423e65cd"&gt;
          &lt;File Id="CefSharp.WinForms.xml" Name="CefSharp.WinForms.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.WinForms.xml" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="CefSharp.xml" Guid="c567fe97-a411-477d-8f5b-82432593c090"&gt;
          &lt;File Id="CefSharp.xml" Name="CefSharp.xml" Source="$(var.EmbeddApp_TargetDir)CefSharp.xml" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="chrome_elf.dll" Guid="8272cf27-65c6-499e-b503-b56ed9f80db1"&gt;
          &lt;File Id="chrome_elf.dll" Name="chrome_elf.dll" Source="$(var.EmbeddApp_TargetDir)chrome_elf.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="d3dcompiler_47.dll" Guid="3405163c-2405-41e7-aeef-3f4f65df1dd2"&gt;
          &lt;File Id="d3dcompiler_47.dll" Name="d3dcompiler_47.dll" Source="$(var.EmbeddApp_TargetDir)d3dcompiler_47.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="devtools_resources.pak" Guid="e2ffd1f6-9283-442f-b83f-fde86ddf1553"&gt;
          &lt;File Id="devtools_resources.pak" Name="devtools_resources.pak" Source="$(var.EmbeddApp_TargetDir)devtools_resources.pak" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="EmbeddApp.pdb" Guid="e040e421-d4b4-4916-9089-f2efb1459594"&gt;
          &lt;File Id="EmbeddApp.pdb" Name="EmbeddApp.pdb" Source="$(var.EmbeddApp_TargetDir)EmbeddApp.pdb" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="icudtl.dat" Guid="a14f1e18-8813-42c1-bad6-f40ad21d1b25"&gt;
          &lt;File Id="icudtl.dat" Name="icudtl.dat" Source="$(var.EmbeddApp_TargetDir)icudtl.dat" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="libcef.dll" Guid="22493d08-ed8f-4bf3-9708-ace297e0d2d7"&gt;
          &lt;File Id="libcef.dll" Name="libcef.dll" Source="$(var.EmbeddApp_TargetDir)libcef.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="libEGL.dll" Guid="8ffc6d72-f929-4162-b7d4-49b8229aeb32"&gt;
          &lt;File Id="libEGL.dll" Name="libEGL.dll" Source="$(var.EmbeddApp_TargetDir)libEGL.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="libGLESv2.dll" Guid="8e759d91-3e4c-4a02-9ba7-6dfaf4c0fa7e"&gt;
          &lt;File Id="libGLESv2.dll" Name="libGLESv2.dll" Source="$(var.EmbeddApp_TargetDir)libGLESv2.dll" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="natives_blob.bin" Guid="15c51480-6cf0-4127-a949-d899ba5a3422"&gt;
          &lt;File Id="natives_blob.bin" Name="natives_blob.bin" Source="$(var.EmbeddApp_TargetDir)natives_blob.bin" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="snapshot_blob.bin" Guid="50f987cb-551e-4734-9d15-b59e0fa7f868"&gt;
          &lt;File Id="snapshot_blob.bin" Name="snapshot_blob.bin" Source="$(var.EmbeddApp_TargetDir)snapshot_blob.bin" /&gt;
        &lt;/Component&gt;
        &lt;Component Id="v8_context_snapshot.bin" Guid="492bb45e-1cdf-4ee1-992f-5479edff99e9"&gt;
          &lt;File Id="v8_context_snapshot.bin" Name="v8_context_snapshot.bin" Source="$(var.EmbeddApp_TargetDir)v8_context_snapshot.bin" /&gt;
        &lt;/Component&gt;
      &lt;!--&lt;Component Id="data_0" Guid="b2f7d81e-587b-4e5e-835a-e29b394ae574"&gt;
          &lt;File Id="data_0" Name="data_0" Source="$(var.EmbeddApp_TargetDir)GPUCache\data_0" /&gt;
        &lt;/Component&gt;--&gt;
  
      &lt;/ComponentGroup&gt;
  
  
    &lt;CustomAction Id="EXECUTE_AFTER_FINALIZE"                  
                Execute="immediate" 
                Impersonate="no"
                Return="asyncNoWait"
                FileKey="EmbeddApp.exe"
                ExeCommand="" /&gt;
  
  &lt;InstallExecuteSequence&gt;
  
    &lt;RemoveExistingProducts Before="InstallInitialize" Overridable="yes" /&gt;
    &lt;Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize"&gt;NOT Installed&lt;/Custom&gt;
  &lt;!--&lt;RemoveExistingProducts Overridable="yes" Sequence="1" /&gt;
    &lt;Custom Action="EXECUTE_AFTER_FINALIZE" After="InstallFinalize"&gt;NOT Installed&lt;/Custom&gt;--&gt;
  &lt;/InstallExecuteSequence&gt;
  
  
    &lt;/Fragment&gt;
  
  
  
  
  
    &lt;!--&lt;Fragment&gt;
      &lt;ComponentGroup Id="ProductSubComponents" Directory="FOLDER1"&gt;
        &lt;Component Id="data_0" Guid="b2f7d81e-587b-4e5e-835a-e29b394ae574"&gt;
          &lt;File Id="data_0" Name="data_0" Source="$(var.EmbeddApp_TargetDir)GPUCache\data_0" /&gt;
        &lt;/Component&gt;
      &lt;/ComponentGroup&gt;
    &lt;/Fragment&gt;--&gt;
  
  
  &lt;/Wix&gt;
  </code></pre>