1

my idea is make an uninstall file with .msi install file. I read some information about creating uninstaller shortcut here: http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_uninstall_shortcut.html , But i cant found information about make uninstall file after msi build , maybe whom know it's possible ? and if possible how i can do it ? or maybe it possible to do with cmd script? Just write script for automatically uninstall my program from mashine. My code is :

    <?xml version="1.0" encoding="UTF-8"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi" xmlns:util="http://schemas.microsoft.com/wix/UtilExtension"><?define WpfApp1_TargetDir=$(var.WpfApp1.TargetDir)?>
    <Product Id="*" Name="SetupProject2" Language="1033" Version="1.0.0.0" Manufacturer="Andrejka" UpgradeCode="PUT-GUID-HERE">
        <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" />

    <Property Id="WIXUI_INSTALLDIR" Value="TESTFILEPRODUCTDIR" />
    <Property Id="WixShellExecTarget" Value="[#WpfApp1.exe]" />
    <CustomAction Id="LaunchApplication" BinaryKey="WixCA"  DllEntry="WixShellExec"   Impersonate="yes" />
    <Property Id="LAUNCH_APP_ON_EXIT" Value="1" />

   <InstallExecuteSequence>
     <Custom Action='LaunchApplication' After='InstallFiles'/>
  </InstallExecuteSequence>   
    <Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOX" Value="1" />

        <MajorUpgrade DowngradeErrorMessage="A newer version of [ProductName] is already installed." />
        <MediaTemplate EmbedCab="yes"/>
        <Feature Id="ProductFeature" Title="SetupProject2" Level="1">
            <ComponentGroupRef Id="ProductComponents" />
        </Feature>
    </Product>

    <Fragment>
        <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="TESTFILEPRODUCTDIR" Name="SetupProject2">
             <Directory Id="ProgramFilesFolder">
                 <Directory Id="INSTALLFOLDER" Name="SetupProject2" />      
       </Directory>
            </Directory>
        </Directory>
    </Fragment>

    <Fragment>
        <ComponentGroup Id="ProductComponents" Directory="INSTALLFOLDER">
            <!-- TODO: Remove the comments around this Component element and the ComponentRef below in order to add resources to this installer. -->
            <!-- <Component Id="ProductComponent"> -->
                <!-- TODO: Insert files, registry keys, and other resources here. -->
            <!-- </Component> -->

            <Component Id="WpfApp1.exe" Guid="*">
              <File Id="WpfApp1.exe" Name="WpfApp1.exe" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe" />     
            </Component>
            <Component Id="WpfApp1.exe.config" Guid="*">
              <File Id="WpfApp1.exe.config" Name="WpfApp1.exe.config" Source="$(var.WpfApp1_TargetDir)WpfApp1.exe.config" />
            </Component>
            <Component Id="aws_sdk_net_core_support.dll" Guid="*">
              <File Id="aws_sdk_net_core_support.dll" Name="aws-sdk-net-core-support.dll" Source="$(var.WpfApp1_TargetDir)aws-sdk-net-core-support.dll" />
            </Component>
            <Component Id="AWSSDK.Core.dll" Guid="*">
              <File Id="AWSSDK.Core.dll" Name="AWSSDK.Core.dll" Source="$(var.WpfApp1_TargetDir)AWSSDK.Core.dll" />
            </Component>
            <Component Id="AWSSDK.SimpleNotificationService.dll" Guid="*">
              <File Id="AWSSDK.SimpleNotificationService.dll" Name="AWSSDK.SimpleNotificationService.dll" Source="$(var.WpfApp1_TargetDir)AWSSDK.SimpleNotificationService.dll" />
            </Component>
            <Component Id="MimeSharp.dll" Guid="*">
              <File Id="MimeSharp.dll" Name="MimeSharp.dll" Source="$(var.WpfApp1_TargetDir)MimeSharp.dll" />
            </Component>
        </ComponentGroup>
    </Fragment>
</Wix>
Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
Андрей Ка
  • 756
  • 4
  • 14
  • 33
  • Welcome to stackoverflow - it took me a while to understand your question, but I am glad you seem to have gotten what you need. Please don't post GUIDs in your sources, people could copy them, and they are then no longer unique (which defeats the whole purpose of GUIDs). This is quite important. If you are not live yet, I would generate new component GUIDs, or better yet, use the concept of setting them to * which will **auto-calculate component GUIDs**. You can also [**simplify your WiX source**](https://stackoverflow.com/questions/24732761/syntax-for-guids-in-wix/24769965#24769965). – Stein Åsmul Oct 13 '17 at 18:21
  • Im here, thanks for answer – Андрей Ка Oct 13 '17 at 18:29
  • The installer and the uninstaller are msiexec (Windows Installer). The msi file is a database, for which WiX is one tool to build it with. – Tom Blodget Oct 13 '17 at 23:14

1 Answers1

0

In general you are not supposed to put uninstall shortcuts in the start menu, it is in fact a violation of Microsoft's logo requirements for Windows applications I believe. Rather you should let people uninstall your product the normal way via the add/remove programs applet.

UPDATE: I found this answer with some more information on this topic: Shortcuts with name "Uninstall <Program Name>" are not displayed in Windows 8/8.1/10

Also, just so it is clear, uninstall, is a built-in feature of MSI files - it is always automatically available unless actively blocked (such as some applications hiding themselves from display in add/remove programs). There is nothing extra you have to do in your WiX sources to support uninstall properly. Just follow Windows Installer guidelines and it comes "for free".

If what you are asking is for a way to create an uninstall batch file, then you can find a plethora of ways to uninstall your MSI file in this "uninstall reference": Uninstalling an MSI file from the command line without using msiexec.

In short, just run the command line below to uninstall your MSI if you have the MSI's product code (you can find your product code by querying your system as described here: How can I find the product GUID of an installed MSI setup? - you might need to look it up since you auto-generate your product code):

msiexec.exe /x {your-product-guid}

or just uninstall by referring to your original MSI installation file like this:

msiexec.exe /x "c:\filename.msi

See the linked answer above (the uninstall reference) for a lot more information about this.

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164