正如标题所说,是否可以使用 Powershell 被动/静默安装 .EXE,但仍然显示安装程序 GUI?我希望下一个自动“单击”,但仍然希望 GUI 显示为进度指示器。
最佳答案
UPDATE: There is a Powershell module for Windows Installer. It can help to run msiexec.exe equivalent commands in easier fashion than to deal with Powershell's quirks.
MSI?:如果这是 EXE 包装器内的 MSI,则以下内容通常可以工作。如果它只是一个普通的 EXE 文件,您应该重新打包为 Painter 答案 - 或者使用正确的开关静默运行它 - 如果可能的话。
MSI 提取:Extract MSI from EXE .
重新打包:最后的手段是使用捕获工具将 EXE 转换为 MSI。
- Quick summary on repackaging (将 setup.exe 转换为 MSI - 更多链接:底部)
- How to run an installation in /silent mode with adjusted settings
Suggestion: I would suggest this command line based on what you wrote (basic UI with modal box displayed at completion & hide the cancel button during installation):
msiexec.exe /I "setup.msi" /qb+!
带有隐藏取消按钮的示例进度对话框:
击键:听起来您希望整个 GUI 向导显示出来,并“自动神奇地”单击所有按钮?那很难。像 AutoIt 这样的疯狂工具(将击键推送到应用程序窗口的工具)可以做到这一点,但这与普通的纸牌屋一样可靠。这种管道胶带方法总是存在错误源。
沉默!:我假设您知道可以使用 msiexec.exe
的标准命令行开关来抑制 MSI 的整个 GUI。 ?您可以选择完全静音的 GUI 或完全像您所描述的进度条以及许多其他组合。您甚至可以隐藏取消按钮。漂亮。
UILevel :MSI支持各种"UILevels" - 安装可以是不同程度的交互性,从完全静音到完全交互。有 4 个基本级别和各种“修饰符”(显示或不显示完成对话框)。以下是实践中不同 UILevel 的答案:Uninstall from Control Panel is different from Remove from .msi
示例:以下是一些进一步的示例命令行:
完全安静,根本没有 GUI:
msiexec.exe /i "setup.msi" /qn
基本 GUI,没有模式对话框和隐藏的取消按钮:
msiexec.exe /i "setup.msi" /qb-!
除了最后显示的模式对话框之外没有 GUI:
msiexec.exe /i "setup.msi" /qn+
注意:还有几种进一步的组合,具体取决于您如何使用 4 different levels of GUI 配置事物。 ,模态对话框是否结束,最后隐藏或显示取消按钮。
高级:除了正常使用 msiexec.exe 之外,您还可以通过 MSI Win32 API 以编程方式抑制 MSI 的整个 GUI,而是自己处理进度消息。
- Handling Progress Messages Using MsiSetExternalUI (C++ 示例代码, also on github.com )
- Serverfault answer on external MSI GUI
WiX bundle :这是 WiX toolkit 的方法用于为 bundle 提供自己的现代 GUI。 Advanced Installer和 Installshield其他人也有类似的概念。与 Windows Installer 的集成全部基于这些 API 调用。
链接:
- Tip: User Interface Levels for MSI Installations
- Uninstall from Control Panel is different from Remove from .msi
- Run MsiExec from PowerShell and get Return Code
重新包装:
关于powershell - 是否可以被动安装 .EXE 但仍使用 Powershell 显示 GUI?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59795440/