[英]Force Inno Setup to show UAC prompt during installation
如果在安装过程中需要特权提升来运行特定的安装程序,如何强制Inno安装程序显示UAC提示? 跳过安装此安装程序并不重要。 我发现可以指定AfterInstall函数来测试是否需要特权提升(IsAdminLoggedOn()),但是如何显示UAC提示以特定用户身份运行此安装程序?
找到了解决方案。 因此,如果在安装过程中需要使用提升的特权运行特定的安装程序,则需要:
在“ Files
部分中指定安装程序,如下所示:
[Files] Source: "SomeSetup.exe"; DestDir: "{tmp}"; AfterInstall: SomeSetupAfterInstall()
在Code
部分中,您应定义SomeSetupAfterInstall()
。 如果不是管理员启动的安装程序,则应使用ShellExec
使用runas
动词运行安装程序。 可能是这样的:
procedure SomeSetupAfterInstall(); var ErrorCode: Integer; TmpPath: String; RunMethod: String; begin TmpPath:=ExpandConstant('{tmp}'); if not IsAdminLoggedOn() then begin RunMethod := 'runas'; end else begin RunMethod := ''; end; ShellExec (RunMethod, TmpPath + '\\SomeSetup.exe', '', '', SW_SHOW, ewWaitUntilTerminated, ErrorCode); end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.