【问题标题】:Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?Inno Setup - 如果设置设置为 Privileges Required=lowest,如何以管理员权限运行应用程序?
【发布时间】:2017-06-15 11:49:08
【问题描述】:

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

我的代码(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;

【问题讨论】:

    标签: inno-setup elevated-privileges


    【解决方案1】:

    使用ShellExecrunas 动词,而不是Exec

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

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

    【讨论】:

    • 是否可以避免消息:“您要允许以下程序对此计算机进行更改吗?”
    • @NicoZ 通过命令行禁用用户帐户控制并重新启用它,为此,请从 pascal 脚本运行这些命令。在 Google 上搜索启用或禁用 UAC CMD
    • @GTAVLover 我找到的所有解决方案都需要重新启动系统。
    • 当然你无法避免UAC提示!这将是一个可怕的安全漏洞!
    • @GTAVLover Nico 在没有管理员权限的情况下运行安装程序。如果没有管理员权限,您将无法禁用 UAC 提示。
    猜你喜欢
    • 2013-09-27
    • 2017-02-23
    • 2013-06-03
    • 1970-01-01
    • 2020-06-11
    • 2015-05-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多