Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inno Setup custom dialog with per user or per machine installation

I'm using Inno Setup (http://www.jrsoftware.org/isinfo.php) to create native bundle for my JavaFX application.

I'd like to create a custom step where ask the user if want a "per user" or "per machine" installation in order to permit both the unprivileged user, and the administrator to install the software.

It's this possible with Inno Setup? And if yes can you provide a trace to follow?

Take a look at this screenshot

enter image description here

like image 316
drenda Avatar asked Dec 17 '15 09:12

drenda


Video Answer


1 Answers

Inno Setup 6

Inno Setup 6 has a built-in support for non-administrative install mode.

Basically, you can simply set PrivilegesRequiredOverridesAllowed:

[Setup]
PrivilegesRequiredOverridesAllowed=commandline dialog

enter image description here


Inno Setup 5

There's no such simple solution, in the previous versions of Inno Setup.

The easiest what you can do is to set PrivilegesRequired directive to none (undocumented value):

[Setup]
PrivilegesRequired=none

This will allow the installer to be run by an unprivileged user. It will install for him/her only.

For a privileged user, the Windows will typically detect that executable is an installer and it will popup a UAC prompt. It will install for all users afterwards.

For details see Make Inno Setup installer request privileges elevation only when needed


To make the installer install to "application data", when run by an unprivileged user, you can do:

[Setup]
DefaultDirName={code:GetDefaultDirName}

[Code]

function GetDefaultDirName(Param: string): string;
begin
  if IsAdminLoggedOn then
  begin
    Result := ExpandConstant('{pf}\My Program');
  end
    else
  begin
    Result := ExpandConstant('{userappdata}\My Program');
  end;
end;

If you really want the user to select, where to install to (though I do not think it is really necessary to allow the Administrator to install for him/herself), you can do this instead of the above DefaultDirName:

[Code]

var
  OptionPage: TInputOptionWizardPage;

procedure InitializeWizard();
begin
  OptionPage :=
    CreateInputOptionPage(
      wpWelcome,
      'Choose installation options', 'Who should this application be installed for?',
      'Please select whether you wish to make this software available for all users ' +
        'or just yourself.',
      True, False);

  OptionPage.Add('&Anyone who uses this computer');
  OptionPage.Add('&Only for me');

  if IsAdminLoggedOn then
  begin
    OptionPage.Values[0] := True;
  end
    else
  begin
    OptionPage.Values[1] := True;
    OptionPage.CheckListBox.ItemEnabled[0] := False;
  end;
end;

function NextButtonClick(CurPageID: Integer): Boolean;
begin
  if CurPageID = OptionPage.ID then
  begin
    if OptionPage.Values[1] then
    begin
      { override the default installation to program files ({pf}) }
      WizardForm.DirEdit.Text := ExpandConstant('{userappdata}\My Program')
    end
      else
    begin
      WizardForm.DirEdit.Text := ExpandConstant('{pf}\My Program');
    end;
  end;
  Result := True;
end;

Installation options

like image 177
Martin Prikryl Avatar answered Nov 01 '22 18:11

Martin Prikryl