Inno设置-如果将设置设置为PrivilegesRequired = lowest,如何使用管理员权限运行复制? [英] Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?

查看:93
本文介绍了Inno设置-如果将设置设置为PrivilegesRequired = lowest,如何使用管理员权限运行复制?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to run the setup with PrivilegesRequired=lowest. How to set and run an application (dxwebsetup.exe) to install with my setup with Administrator privileges?

我的代码( Inno设置-避免显示子安装程序的文件名):

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提示.

When the current Inno Setup process runs without Administrator privileges, you will get a UAC prompt.

这篇关于Inno设置-如果将设置设置为PrivilegesRequired = lowest,如何使用管理员权限运行复制?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆