Modify Inno Setup Run section flags according to selected installation type

95 Views Asked by At

I have a Run section:

[Run]
Filename: "{app}\myapp.exe"; Description: {cm:RunNow}; \
    Flags: postinstall nowait runascurrentuser;  Check: TypeIsCompact;
Filename: "{app}\myapp.exe"; Description: {cm:RunNow}; \
    Flags: postinstall nowait runasoriginaluser; Check: not TypeIsCompact;

And the check TypeIsCompact:

function TypeIsCompact: Boolean;
begin  
  if SILENT then
    begin
      Result := DONTINSTALLMSSQL;
    end
  else
    begin
      Result := WizardForm.TypesCombo.ItemIndex = 1;
    end;
  log('Type is compact: ' + BoolToStr(Result));
end;

The check called in the Run section returns True despite type was not selected yet. With this I'm not able to use the Filename with flag runasoriginaluser and myapp.exe is starting with the flag runascurrentuser.

I need to run myapp.exe with or without administrator privileges depending on the chosen type.

Is there any direct way or do I have to write custom checkbox for the finish page?

1

There are 1 best solutions below

0
Martin Prikryl On

You do not have to create your own check box. But I believe you need to implement the execution of the program on your own.

For some example how to re-implement handling of the checkboxes on the "finished" page, see:
Running script code (adding a registry key) instead of executable in Run entry in Inno Setup

In your implementation, use Exec or ExecAsOriginalUser, depending on the installation type selected.