WiX安装程序删除升级时的快捷方式

时间:2017-05-19 08:27:05

标签: wix windows-installer wix3.11

我正在使用WiX Toolkit v3.11来创建我的软件设置。在安装过程中,我使用以下代码创建startmenu快捷方式:

<Shortcut Id='startmenuMyProgram'
          Name='$(var.MyProgramName)'
          Directory='ProgramMenuFolder'
          WorkingDirectory='APPLICATIONFOLDER'
          Advertise='yes'
          Icon='icon.exe'>
  <Icon Id='icon.exe' SourceFile='$(var.Setuppath)\MyProgram.exe'/>
</Shortcut>

通过这种方式,我还为其他可执行文件创建了两个快捷方式。现在为了卸载我想删除快捷方式。

<Component Id="removeStartmenuShortcuts" Guid="803ad14a-feab-4901-b9db-2c4a1298ae8b">
  <Condition>(REMOVE=ALL) AND NOT (WIX_UPGRADE_DETECTED OR UPGRADINGPRODUCTCODE)</Condition>

  <RemoveFile Id="remove_startmenuProgram1" Name="startmenuMyProgram" On="uninstall" />
  <RemoveFile Id="remove_startmenuProgram2" Name="startmenuMyProgram2" On="uninstall"/>
  <RemoveFile Id="remove_startmenuProgram3" Name="startmenuMyProgram3" On="uninstall"/>
</Component>

卸载软件时,这没有任何问题。但是,执行更新时也会删除快捷方式。但我想阻止这种行为,但条件似乎不起作用。因此,当我进行更新时,将删除Windows任务栏中的所有快捷方式。

如何让我的更新进度正常工作?

此处更新后的行为:

Behavior when doing an update

右侧所有快捷方式的组都丢失了!

1 个答案:

答案 0 :(得分:0)

您可以组合2个组件。这样你就不需要使用条件语句了。

注册表值是在组件下设置密钥路径。

  <Component Id="cmpstartmenuMyProgram" Guid="{67CB4F7A-5028-4697-A47F-DE99110B9645}">
    <Shortcut Id="Shortcut.ApplicationName"
              Name="ApplicationName"
              Target="[INSTALLDIR]ApplicationName.exe"
              WorkingDirectory="INSTALLDIR"
              Directory="StartMenuFolder"
              Icon="Icon.exe"/>
    <RemoveFile Id="RemoveStartMenuShortcut.ApplicationName" Name="ApplicationName" Directory="StartMenuFolder" On="uninstall"/>
    <RegistryValue Root="HKCU" Key="Software\Compony\ComponyName" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
  </Component>
相关问题