【问题标题】:WIX - Creating an uninstall shortcut inside installed folderWIX - 在已安装文件夹中创建卸载快捷方式
【发布时间】:2015-06-19 20:52:49
【问题描述】:

我正在使用 Wix 3.9 和 Wix-edit 0.7.5/Notepad++ 为我的应用程序创建 MSI 安装程序。我想在已安装的文件夹中创建一个卸载快捷方式。例如:

C:\MySoftware\Uninstall.lnk

我尝试了一些方法,但在所有情况下,当我通过该链接卸载软件时,程序文件夹C:\MySoftware 都不会被删除。以其他方式卸载按预期工作。

首先,我尝试将其创建为<Directory> 标记内的组件。在我看来有点hacky,因为我必须添加<CreateFolder>

<Directory Id="MYINSTALLDIR" Name="MySoftware">
    <!-- my files... -->

    <Component Id="ABC" Guid="PUT-GUID-HERE">
        <CreateFolder/> <!-- have to add this -->
        <Shortcut Id="UninstallProduct" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/>
    </Component>

</Directory>

<Feature Id="DefaultFeature" Title="Main Feature" Level="1">
    <!-- some references... -->
    <ComponentRef Id="ABC" />
</Feature>

我还尝试将&lt;CreateFolder/&gt; 替换为&lt;RemoveFolder Id="MYINSTALLDIR" On="uninstall" /&gt;,结果相同。

再试一次:

<DirectoryRef Id="ApplicationProgramsFolder">
    <Component Id="StartMenuShortcuts" Guid="*">
        <RemoveFolder Id="ApplicationProgramsFolder" On="uninstall" />
        <RegistryValue Root="HKCU" Key="Software\[Manufacturer]\[ProductName]" Type="string" Value="" />
        <Shortcut Id="UninstallProduct1" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]"/>
        <Shortcut Id="UninstallProduct2" Name="Uninstall MySoftware" Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe" Arguments="/x [ProductCode]" Directory="MYINSTALLDIR" />
    </Component>
</DirectoryRef>

在这里,除了得到相同的结果外,我在构建时收到警告:file.wxs(31) : warning LGHT1076 : ICE57: Component 'StartMenuShortcuts' has both per-user and per-machine data with an HKCU Registry KeyPath.

如何创建可以在不影响卸载行为的情况下使用的快捷方式?我不知道这是否有区别,但我需要它在没有管理员权限的情况下工作(我使用的是&lt;Package ... InstallScope="perUser" InstallPrivileges="limited"&gt;)。

我知道我可以只创建一个 .lnk 文件并将其添加到项目中,但我不想这样做,因为那样我就不得不担心在每个项目上更新它的 GUID。

【问题讨论】:

  • 检查是否在 RemoveFolders 之前安排了动作 RemoveShortcuts 和 RemoveRegistryValues。您可以使用 Orca 来做到这一点。
  • 在 Orca 中,“InstallExecuteSequence”条目有几个动作,然后依次是:“RemoveRegistryValues”、“RemoveShortcuts”和“RemoveFiles”。是不是当我通过快捷方式卸载时,Windows 会打开那个“.lnk”文件?因为当我通过开始菜单链接或控制面板卸载时,我看不到这种行为。
  • 你的假设是有道理的。我会调查我的电脑是否发生同样的情况。

标签: wix windows-installer wix3.9


【解决方案1】:

出现问题是因为您没有为 msiexec 设置工作目录,然后它将使用当前目录,引发错误 2911(无法删除文件夹)。

添加对WindowsFolder的引用:

<Directory Id="MYINSTALLDIR" Name="MySoftware">
    ...
    <Directory Id="WindowsFolder" Name="WindowsFolder" />
</Directory>

然后修改你的快捷方式添加属性WorkingDirectory="WindowsFolder":

<Shortcut Id="UninstallProduct" Name="Uninstall MySoftware" 
          Description="Uninstalls MySoftware" Target="[System64Folder]msiexec.exe"
          Arguments="/x [ProductCode]" WorkingDirectory="WindowsFolder" />

【讨论】:

  • 太棒了!非常感谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-06-28
  • 1970-01-01
  • 2016-07-14
  • 2011-02-10
  • 2011-02-25
相关资源
最近更新 更多