2
votes

I want to run the installer in non-admin mode. However, when some driver is missing I wish to install it. Since change directive value from [Code] isn't possible, I was thinking if I can get the current mode of execution then I build my logic.

[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() returns the value that is given [Setup] section. But I wish to get the value that indicates that the exe is currently running in admin mode. If I get a different value then, I can add it to if clause and continue the setup.

This won't work as because I need a silent installation:
Inno Setup - How to run an aplication with admin privileges if the setup is set to PrivilegesRequired=lowest?

1

1 Answers

1
votes

To test if the installer is running with Administrator privileges, use IsAdmin function.