Inno Setup Load defaults for custom installation settings from a file (.inf) for silent installation

前端 未结 1 521
既然无缘
既然无缘 2021-01-06 19:02

I have a setup script that allows the user to specify where they would like to install my application. It is in the form of a Pascal script within the [Code] b

相关标签:
1条回答
  • 2021-01-06 19:26

    You can add a custom key (say Users) to the .inf file created by the /SAVEINF.

    Then in the installer, lookup the /LOADINF command-line argument and read the key and act accordingly:

    procedure InitializeWizard();
    var
      InfFile: string;
      I: Integer;
      UsersDefault: Integer;
    begin
      ...
    
      InfFile := ExpandConstant('{param:LOADINF}');
    
      UsersDefault := 0;
    
      if InfFile <> '' then
      begin
        Log(Format('Reading INF file %s', [InfFile]));
        UsersDefault :=
          GetIniInt('Setup', 'Users', UsersDefault, 0, 0, ExpandFileName(InfFile));
        Log(Format('Read default "Users" selection %d', [UsersDefault]));
      end
        else
      begin
        Log('No INF file');
      end;
    
      SelectUsersPage.Values[UsersDefault] := True;
    end;
    
    0 讨论(0)
提交回复
热议问题