【发布时间】:2023-03-10 19:00:01
【问题描述】:
我正在为之前使用 ClickOnce 部署的应用程序编写 WiX 安装程序。
我想检测应用程序是否安装在客户端计算机上并中止 MSI 安装。我在 StackOverflow 上搜索了类似的问题,但找不到解决方法。
如果我可以找到告诉我应用程序安装位置的路径或某个注册表项,我可以通过条件中止 MSI 安装。
使用this question 的答案,我能够到达某个地方。 ClickOnce 快捷方式是具有 .appref-ms 扩展名的文件。这是我使用的代码:
<Property Id="APP_CLICKONCE_INSTALLED">
<DirectorySearch Id="dirSearch.APP.CLICKONCE" AssignToProperty="yes" Path="[StartMenuFolder]" Depth="2">
<FileSearch Id="fileSearch.APP.CLICKONCE" Name="APP.appref-ms" />
</DirectorySearch>
</Property>
<Condition Message="App is already installed. Please uninstall it then re-run this setup.">
<![CDATA[APP_CLICKONCE_INSTALLED = "" OR INSTALLED]]>
</Condition>
但是,StartMenuFolder 提供了 AllUsers 配置文件的位置,而单击一次应用程序是为当前用户安装的。我还在挖。
使用 perUser 安装 StartMenuFolder 提供当前用户位置(我使用的是 perMachine):
<Package InstallerVersion="200" Compressed="yes" InstallScope="perUser" />
现在一切都很好。
【问题讨论】:
标签: wix clickonce windows-installer