每个用户或每台机器安装的Inno Setup自定义对话框 [英] Inno Setup custom dialog with per user or per machine installation

查看:249
本文介绍了每个用户或每台机器安装的Inno Setup自定义对话框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Inno设置(

解决方案

在Inno Setup中没有简单的解决方案。



最简单的方法是设置


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

解决方案

There's no simple solution for this in 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;

这篇关于每个用户或每台机器安装的Inno Setup自定义对话框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆