[英]Force Inno Setup to show UAC prompt during installation
How can I force Inno Setup to show UAC prompt if elevated privileges are required to run specific installator during my setup? 如果在安装过程中需要特权提升来运行特定的安装程序,如何强制Inno安装程序显示UAC提示? Skipping to install this installator is not critical.
跳过安装此安装程序并不重要。 I found out that I can specify AfterInstall function to test if privilege elevation is required (IsAdminLoggedOn()), but how to show UAC prompt to run this installator as specific user?
我发现可以指定AfterInstall函数来测试是否需要特权提升(IsAdminLoggedOn()),但是如何显示UAC提示以特定用户身份运行此安装程序?
Found the solution. 找到了解决方案。 So, if you need to run specific installator with elevated privileges during your setup you need:
因此,如果在安装过程中需要使用提升的特权运行特定的安装程序,则需要:
Specify your installator in Files
section as follows: 在“
Files
部分中指定安装程序,如下所示:
[Files] Source: "SomeSetup.exe"; DestDir: "{tmp}"; AfterInstall: SomeSetupAfterInstall()
In Code
section you shall define SomeSetupAfterInstall()
. 在
Code
部分中,您应定义SomeSetupAfterInstall()
。 There you should run your installator with runas
verb using ShellExec
if it is not admin launched setup. 如果不是管理员启动的安装程序,则应使用
ShellExec
使用runas
动词运行安装程序。 It might be like this: 可能是这样的:
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.