Inno Setup - 如果安装设置为PrivilegesRequired = lowest,如何使用管理员权限运行应用程序?
问题描述:
我想用PrivilegesRequired=lowest
运行设置。如何设置和运行应用程序(dxwebsetup.exe)以使用具有管理员权限的设置进行安装?Inno Setup - 如果安装设置为PrivilegesRequired = lowest,如何使用管理员权限运行应用程序?
我的代码(Inno Setup - Avoid displaying filenames of sub-installers):
procedure CurStepChanged(CurStep: TSetupStep);
var
ProgressPage: TOutputProgressWizardPage;
ResultCode: Integer;
begin
if CurStep = ssInstall then
begin
if IsComponentSelected('DirectX') then
begin
ProgressPage := CreateOutputProgressPage('Installing prerequsities', '');
ProgressPage.SetText('Installing DirectX...', '');
ProgressPage.Show;
try
ExtractTemporaryFile('dxwebsetup.exe');
StartWaitingForDirectXWindow;
Exec(ExpandConstant('{src}\_Redist\dxwebsetup.exe'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
finally
StopWaitingForDirectXWindow;
ProgressPage.Hide;
end;
end;
end;
end;
答
使用ShellExec
与runas
动词,而不是Exec
:
ShellExec('runas', ExpandConstant('{src}\_Redist\dxwebsetup.exe'), '', '', SW_SHOW,
ewWaitUntilTerminated, ResultCode);
当电流Inno Setup的过程中没有管理员权限运行,你会得到一个UAC提示。
是否可以避免该消息:“您是否希望允许以下程序对此计算机进行更改?” –
@NicoZ通过命令行禁用用户帐户控制并重新启用它,为此,请从pascal脚本运行这些命令。搜索Google for *启用或禁用UAC CMD *。 – GTAVLover
@GTAVLover我发现的所有解决方案都需要重新启动系统。 –