如何与静默安装的 msi 交互? (进度数据并取消)

发布于 2024-08-09 20:44:37 字数 155 浏览 4 评论 0原文

由于某种原因,我们正在提供带有我们自己的安装 GUI 的产品,这意味着我们将在后台静默运行 msi 安装。

通过使用 MSI API“MsiInstallProduct”,我可以静默安装该产品,但我不知道如何获取此安装的进度数据以及如何取消它。

有人有一些想法吗?

For some reason, we are delivering a product with our own install GUI, that means, we will run the msi installation silently background.

By using the MSI API "MsiInstallProduct", I can install the product silently, but I have no idea how can I get the progress data of this installation and how can I cancel it.

Anyone has some ideas?

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

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

发布评论

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

评论(3

陌伤ぢ 2024-08-16 20:44:37

2018 年 6 月更新:虽然下面显示的工具不再可供下载,但我通过 Wayback machine 找到了它。我认为链接到它是可以并且合法的,因为该工具是免费软件。更新了以下链接。

更新遗憾的是,Wise 的这个工具无法再下载。我也不确定是否可以分发它。它似乎是一个免费工具,作为其主要 Wise Package Studio 套件的一部分分发,但我不认为它是开源的。我希望他们能够将其作为开源工具发布。

由于许多法律问题


我相信您可以通过 MSI API 获取进度,但如果我是您,我只会在通过 msiexec.exe 调用安装后显示 MSI 本身的进度条。

MSI 支持多种不同的安装级别(完全、完全静默、基本 GUI、精简 GUI 等)。就您而言,听起来您想要一个基本的用户界面。这会产生一个进度条,您可以在其中隐藏取消按钮,并可选择显示完成模式对话框:

使用进度栏静默安装,没有取消按钮,最后没有模式对话框:

msiexec.exe /I "Test.msi" /QB-!

为了避免必须构建这些手动使用愚蠢的 msiexec 命令行,使用 Wise 的 msi 命令行构建器工具http://www2.wise.com/filelib/WICLB.exe从 Wayback 机器复活)。

为了安全起见,请通过 virustotal.com 运行下载。

在此处输入图像描述


相关

UPDATE June 2018: Although the tool shown below is no longer available for download, I found it via Wayback machine. I assume it is OK and legal to link to it, seeing as the tool was freeware. Updated links below.

UPDATE: This tool from Wise is regrettably not downloadable anymore. I am not sure if it is OK to distribute it either. It seemed to be a free tool distributed as part of their main Wise Package Studio suite, but I don't think it is open source. I wish they would release it as an open source tool.

The Wise packaging products have been discontinued due to a number of legal issues.


I believe you can get the progress via the MSI API, but if I were you I would just show the progress bar from the MSI itself after invoking the install via msiexec.exe.

MSI supports several different installation levels (full, completely silent, basic GUI, reduced GUI etc...). In your case it sounds like you want a basic UI. This yields a progress bar where you can hide the cancel button, and optionally show a completion modal dialog:

Install silently with progress bar, no cancel button and no modal dialog at end:

msiexec.exe /I "Test.msi" /QB-!

To avoid having to construct these silly msiexec command lines manually, use the msi command line builder tool from Wise: http://www2.wise.com/filelib/WICLB.exe (resurrected from Wayback machine).

Please run the download by virustotal.com for safety.

enter image description here


Related:

ら栖息 2024-08-16 20:44:37

这是一个示例项目,似乎可以完成您所指的操作:
http://www.codeproject.com/KB/cs/msiinterop.aspx

Here is a sample project that appears to do what you are referring to:
http://www.codeproject.com/KB/cs/msiinterop.aspx

紫﹏色ふ单纯 2024-08-16 20:44:37

您需要在 MsiInstallProduct 之前使用 MsiSetExternalUI 或 MsiSetExternalUIRecord 指定外部 UI 处理程序(后者更好,但具有更高的 MSI 版本要求)。 Windows Installer 希望您处理的每条消息都会调用您指定的函数。这将为您提供数据,并有机会回复并告知其取消。如果您需要 MSI 4.5 或更高版本,则可以使用嵌入式外部 UI 处理程序 DLL,它不需要引导程序。

You need to specify an external UI handler using MsiSetExternalUI or MsiSetExternalUIRecord before MsiInstallProduct (the latter is nicer, but has a higher MSI version requirement). The function you specify will be called for each message Windows Installer wants you to process. This will give you the data, and a chance to respond tell it to cancel. If you require MSI 4.5 or later, you can use an embedded external UI handler DLL, which does not require a bootstrap.

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