如何确定以前的 WIX Install 安装程序的文件夹

发布于 2024-12-04 07:19:26 字数 190 浏览 2 评论 0原文

我们产品的现有安装程序不会向注册表写入任何信息,也不写入任何自定义环境变量。允许用户在安装程序的 UI 中更改安装目录。当我进行升级时,如何找出先前版本安装到哪个文件夹中?

我需要知道该文件夹,以便我可以找到以前的配置文件&从中复制值。新版本的配置文件有新的标签和新的结构,所以我不能只保留以前的文件和文件。重复使用它。

托尼

The existing installer for our product does not write any information to the registry, nor does it write any custom environment variables. The user is allowed to change the install directory in the installer's UI. When I'm doing an upgrade, how do I find out what folder the previous version was installed into?

I need to know the folder so I can find the previous configuration file & copy values from it. The new version's configuration file has new tags and a new structure, so I can't just keep the previous file & reuse it.

Tony

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

相守太难 2024-12-11 07:19:26

MSI 没有直接获得该信息。 (MSI 包可以有多个“根”目录,因此无法确定开发人员可能需要哪一个。)如果注册表中有该目录,请使用 注册表搜索。否则,您可以在中使用 MsiGetComponentPath自定义操作。

MSI doesn't have that information directly. (MSI packages can have multiple "root" directories, so there's no telling which one a developer might want.) If you have the directory in the registry, use RegistrySearch. Otherwise, you can use MsiGetComponentPath in a custom action.

能否归途做我良人 2024-12-11 07:19:26

我对此进行了一些研究,这是我提出的解决方案:

当安装程序完成安装时,它会在注册表中的路径下创建一个节点,

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

以便在 32 位操作系统上进行 32 位安装,或在 64 位操作系统上进行 64 位安装,或

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

在 64 位操作系统上安装 32 位。

该节点包含一个名为 InstallLocation 的值,它为您提供可执行文件的安装路径。

不幸的是,我们的安装程序的早期版本没有设置此属性,因此我无法使用它。但是我们的安装程序创建了一个服务。我已在注册表中找到该服务的节点路径。从那里,我可以检索 ImagePath 值并从服务的 .EXE 文件名中提取路径。

所以我的解决方案是:

  1. 修复新的安装程序,使其设置 InstallLocation 值。
  2. 仅当从以前的版本升级时,它将检索服务和服务的注册表节点。使用服务的 ImagePath 密钥。
  3. 如果从任何更高版本升级,我们将检索 Uninstall 节点并使用 InstallLocation 键。

托尼

I've done some research into this and here's the solution that I came up with:

When the installer finishes installing, it creates a node in the registry under the path

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

for 32 bit installs on 32 bit OS or 64 bit installs on 64 bit OS, or

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows\CurrentVersion\Uninstall\<Product ID>

for 32 bit installs on 64 bit OS.

This node contains a value called InstallLocation which gives you the path to where the executables are installed.

Unfortunately, the previous version of our installer did not set this property, so I can't use it. BUT our installer creates a Service. I have found the path to the node in the registry for that service. From there, I can retrieve the value of the ImagePath value and extract the path from the service's .EXE file name.

So my solution is to:

  1. Fix the new installer so it does set the InstallLocation value.
  2. When upgrading from the previous version only, it will retrieve the registry node for the service & use the service's ImagePath key.
  3. If upgrading from any later version, we'll retrieve the Uninstall node and use the InstallLocation key.

Tony

过度放纵 2024-12-11 07:19:26

msiexec 保留上次安装的 msi 副本,因此它将处理卸载以前的版本,您只需包含 InstallExecuteSequence 部分。

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>

这仅在您在 Product 元素中使用相同的 UpgradeCode 属性时才有效。

祝你好运!

msiexec keeps a copy of the msi from the last install so it will handle uninstalling the previous version you will need to just include the InstallExecuteSequence section

<InstallExecuteSequence>
  <RemoveExistingProducts After="InstallValidate" />
</InstallExecuteSequence>

This will only work if you are using the same UpgradeCode attribute in your Product Element.

Good Luck!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文