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
Inno Setup 6 has a built-in support for non-administrative install mode.
Basically, you can simply set PrivilegesRequiredOverridesAllowed
:
[Setup]
PrivilegesRequiredOverridesAllowed=commandline dialog
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;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With