2017-10-13 108 views
1

我的想法是使用.msi安装文件创建卸载文件。我阅读了一些关于在这里创建卸载程序快捷方式的信息:http://wixtoolset.org/documentation/manual/v3/howtos/files_and_registry/create_uninstall_shortcut.html,但是我无法找到有关在msi构建后制作卸载文件的信息,或许谁知道它是可能的?如果可能的话我该怎么做呢?或者也许有可能做的CMD脚本?只需编写脚本即可自动从mashine中卸载我的程序。我的代码是:Wix创建无声卸载文件

<?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> 
+0

欢迎来到stackoverflow - 我花了一段时间来理解你的问题,但我很高兴你似乎得到了你需要的东西。请不要在源中发布GUID,人们可以复制它们,然后它们不再是唯一的(这会破坏GUID的全部目的)。这非常重要。如果您还没有生活,我会生成新的组件GUID,或者更好的是,使用将它们设置为*的概念,它将自动计算组件GUID **。您也可以[**简化您的WiX源代码**](https://stackoverflow.com/questions/24732761/syntax-for-guids-in-wix/24769965#24769965)。 –

+0

我在这里,感谢您的回答 – Andrej

+0

安装程序和卸载程序是msiexec(Windows安装程序)。 msi文件是一个数据库,为此,WiX是一个可用于构建它的工具。 –

回答

0

一般来说,你不应该把卸载快捷方式在开始菜单中,它实际上是侵犯了微软的Windows应用程序,我相信徽标要求。相反,您应该让人们通过添加/删除程序小程序以正常方式卸载您的产品。

更新:我发现这个答案对这个话题的一些详细信息:Shortcuts with name "Uninstall <Program Name>" are not displayed in Windows 8/8.1/10

而且,只是所以很显然,卸载,是一个内置的MSI文件的功能 - 它总是自动提供除非主动阻止(例如某些应用程序隐藏自己不能在添加/删除程序中显示)。您的WiX资源中无需额外支付任何额外费用即可支持正确卸载。只需按照Windows Installer指南进行操作即可免费获得。

如果你问的是一个方法来创建一个卸载批处理文件,然后你可以找到方法来卸载MSI文件在这个“卸载参考”过多:Uninstalling an MSI file from the command line without using msiexec

简而言之,如果您有MSI的产品代码,您只需运行下面的命令行卸载您的MSI(您可以通过查询您的系统找到您的产品代码:How can I find the product GUID of an installed MSI setup? - 您可能需要查看它自动生成你的产品代码):

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

或只是参照原来的MSI安装文件这样的卸载:

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

见上文(卸载参考链接的答案)的多很多有关此信息。