如何在静默安装期间处理 Python 安装程序弹出窗口?

问题描述 投票:0回答:0

我想静默安装我的 NSIS installer.exe,但在其中一个阶段,默认情况下它将下载 Python 作为安装的一部分,并弹出另一个弹出的“修改设置”页面: Python Modify Setup Pop Up

即使我点击“修复”并等待它完成并退出,安装程序也没有完成(实际安装没有完成,我没有安装任何东西)。 有没有办法让我处理这个 python 安装程序弹出窗口并确保我的安装程序完成?

谢谢。

备选方案 我尝试在 PowerShell 脚本中使用 [System.Windows.Forms.SendKeys] 来逐步安装程序并手动取消选中它通过以下方式下载 Python 的框:

# Uncheck Python Installer
[System.Windows.Forms.SendKeys]::SendWait("{DOWN}")
[System.Windows.Forms.SendKeys]::SendWait(" ")
[System.Windows.Forms.SendKeys]::SendWait("{ENTER}")

但是在跳过 Python 安装程序之后,我必须等待实际安装完成才能发送另一个“ENTER”命令。有没有办法让我优雅地等待安装,例如。等待“下一步”按钮响应?我不想使用硬编码的 Start-Sleep 命令。

我尝试使用 DllImports 'user32.dll' 来检查按钮是否已启用,但它不起作用。

[DllImport("user32.dll", SetLastError = true)]
public static extern IntPtr FindWindowEx(IntPtr parentHandle, IntPtr hWndChildAfter, string className, string windowTitle);

[DllImport("user32.dll", SetLastError = true)]
public static extern bool IsWindowEnabled(IntPtr hWnd);
windows powershell installation nsis
© www.soinside.com 2019 - 2024. All rights reserved.