installation - 在 Inno Setup 中以管理员权限执行安装后程序(子安装程序),即使主安装程序没有它们

标签 installation inno-setup elevated-privileges

就像在 this question 中一样,我正在尝试实现一个安装程序,该安装程序在安装结束时启动另一个第 3 方驱动程序安装程序。

这是通过使用管理权限运行我的安装程序来实现的(如果未指定,这是默认设置):

[Setup]
PrivilegesRequired=admin

然后在最后使用runascurrentuser:

Filename: "{app}\drivers\driver.exe"; Description: "Install optional drivers"; \
    Flags: postinstall skipifsilent runascurrentuser

如果用户从一开始就拥有管理员权限,则此方法有效。

但是,即使用户没有管理员权限,我也希望允许安装基本应用程序。只有在安装可选驱动程序时,Windows 才会弹出“用户帐户控制”窗口,如果用户不是管理员,则要求输入管理员密码。

因此,我想在没有提升权限的情况下启动安装程序,并且只有在(以及何时)要启动可选的 diver 安装时才提升为管理员权限。

最佳答案

如果你想让 [Run] 条目“以管理员身份运行”,无论安装程序的权限是什么,都尝试添加 runas Verb(必须与 shellexec flag 结合,反过来暗示 nowait ,所以你可能想明确地添加 waituntilterminated ):

[Run]
Filename: "{app}\drivers\driver.exe"; \
    Description: "Install optional drivers"; \
    Verb: runas; \
    Flags: postinstall skipifsilent runascurrentuser shellexec waituntilterminated

它也可以通过 Pascal 脚本实现:
Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?

关于installation - 在 Inno Setup 中以管理员权限执行安装后程序(子安装程序),即使主安装程序没有它们,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74125021/

相关文章:

python - 如何修复安装 Jupyter Notebook 时发生的错误?

installation - tensorflow 安装问题 :ImportError: No module named tensorflow

macos - 无法读取opensslv.h :No such file or directory

python - 导入错误: No module named numpy on Ubuntu after Numpy Installation

inno-setup - 如何在 Inno Setup 中最小化安装程序?

java - 如何在 javafx 应用程序中添加许可证/安装文件夹屏幕

inno-setup - Inno Setup : Keep existing 32-bit installation path for upgrades, 使用 64 位路径进行新安装

windows - 标准用户登录时启动管理交互进程

c# - 如何让控制台应用程序始终以管理员身份运行?