【问题标题】:Test if Inno Setup installer is running with Administrator privileges测试 Inno Setup 安装程序是否以管理员权限运行
【发布时间】:2020-05-27 19:26:30
【问题描述】:

我想在非管理员模式下运行安装程序。但是,当缺少某些驱动程序时,我希望安装它。由于无法从[Code] 更改指令值,因此我在考虑是否可以获得当前的执行模式,然后构建我的逻辑。

[Setup]
PrivilegesRequired=lowest

[Code]

function IsKvaserNotInstalled: boolean;
begin
  Result := Not RegKeyExists(HKEY_LOCAL_MACHINE, 'driver path');
end;

function MyConst(): String;
begin
  Result := '{#SetupSetting("PrivilegesRequired")}';
  MsgBox(Result, mbInformation, MB_OK);
end;

function InitializeSetup(): Boolean;
begin
  MyConst();
  if IsKvaserNotInstalled() then begin
    MsgBox('KVASER driver is not installed. ' +
           'We require setup to run in admin mode to install it.', mbInformation, MB_OK);
    Result := false;
  end else
    Result := true;   
end;

function IsKvaserNotInstalled: boolean;
begin
  result := Not RegKeyExists(HKEY_LOCAL_MACHINE,
    'SOFTWARE\KVASER AB\CANDriver 1.0\Drivers\kcanv');
end;

[Run]
Filename: "{app}\drivers_setup.exe"; Parameters: "/S" ; Check: IsKvaserNotInstalled;

MyConst() 返回给定 [Setup] 部分的值。但我希望获得表明 exe 当前以管理员模式运行的值。如果我得到一个不同的值,我可以将它添加到 if 子句并继续设置。

这不起作用,因为我需要静默安装:
Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?

【问题讨论】:

    标签: installation inno-setup pascalscript elevated-privileges


    【解决方案1】:

    要测试安装程序是否以管理员权限运行,请使用IsAdmin function。

    【讨论】:

      猜你喜欢
      • 2020-06-11
      • 2015-05-21
      • 2022-10-24
      • 1970-01-01
      • 2017-02-23
      • 2011-05-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多