如何使Inno Setup / DIR命令行开关与自定义路径页一起使用

时间:2017-09-24 17:10:36

标签: inno-setup pascalscript

当我使用/ DIR命令行开关

"Mysoft.exe" /VERYSILENT /installerbusiness /DIR="C:\Program Files (x86)"

指定的路径不会用于我的自定义页面上的路径框:

我正在使用基于Use two/multiple selected directories from custom page in Files section的代码。

这是我正在使用的代码示例。

[Code]

var
  Install: TInputDirWizardPage;

procedure InitializeWizard();
begin
  Install :=
    CreateInputDirPage(
      wpSelectDir, CustomMessage('Readyinstall'), 
      CustomMessage('Readyinstallpc'), #13#10#13#10 + CustomMessage('Tocontinuet'),
      True, 'Mysoft');

  Install.Add(CustomMessage('DestFolder'));

  Install.Values[0] := ('C:\Program Files\Mysoft');
  { ... }
end;

1 个答案:

答案 0 :(得分:1)

如果您想要"安装路径"的标准行为? Inno安装程序,当包括/DIR= command-line switch的处理时,您必须将自定义路径框链接到标准路径框。

特别是,您必须将WizardForm.DirEdit的初始值复制到自定义框中:

var
  Page: TInputDirWizardPage;

procedure InitializeWizard();
begin
  ...
  Page := CreateInputDirPage(...);
  Page.Add(...);
  Page.Values[0] := WizardForm.DirEdit.Text;
end;

此解决方案不仅处理/DIR=,还处理/LOADINF=

要补充上面的代码,您应该将值复制回WizardForm.DirEdit。这样,您可以确保在重新安装/升级时,重复使用先前选择的值。这在我对Use two/multiple selected directories from custom page in Files section的答案的第1点中显示。

如果执行上述过于复杂(或不明显),由于安装程序逻辑复杂,您可以自己以编程方式处理/DIR=开关。请参阅Setting value of Inno Setup custom page field from command-line

procedure InitializeWizard();
var
  DirSwitchValue: string;
begin
  Install := ...;

  Install.Add(...);

  DirSwitchValue := ExpandConstant('{param:DIR}');
  if DirSwitchValue <> '' then
  begin
    Install.Values[0] := DirSwitchValue;
  end
    else
  begin
    Install.Values[0] := ExpandConstant('{pf}\Mysoft');
  end;
end;

此解决方案显然无法处理/LOADINF=。如何处理.inf文件显示在Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation

此外,使用此解决方案,以前使用的安装路径不会用于升级/重新安装。如何实现它显示在Inno Setup with three destination folders

相关问题