Inno Setup - 如果设置设置为 Privileges Required=lowest,如何 运行 具有管理员权限的应用程序?

Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?

我想 运行 使用 PrivilegesRequired=lowest 进行设置。如何设置和 运行 一个应用程序 (dxwebsetup.exe) 以使用我的管理员权限安装?

我的代码():

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;

使用 ShellExecrunas 动词,而不是 Exec:

ShellExec('runas', ExpandConstant('{src}\_Redist\dxwebsetup.exe'), '', '', SW_SHOW,
          ewWaitUntilTerminated, ResultCode);

当当前的 Inno Setup 进程在没有管理员权限的情况下运行时,您将收到 UAC 提示。