inno-setupinno-setup-v6

Install App in VERYSILENT mode with command line which written with inno setup script


How Should i modify my code so i can let user detemine the path of second directory (path of java in script)

I used this Command befor i try in mode:

mysetup.exe /DIR="C:\test"

installation path second path And how to let user to choose one of these Component1 or component2 or both. choose component to be installed

#define AppName "My App"
[Setup]
AppName={#AppName}
AppVersion=1
DefaultDirName={code:getInstallDir}\{#AppName}
;DefaultDirName={pf}\My App
DisableDirPage=yes

[Files]

[Code]

#include 'System.iss'
var
  Page: TInputDirWizardPage;
  UsagePage: TInputOptionWizardPage;

function InputDirPageNextButtonClick(Sender: TWizardPage): Boolean;
begin
  { Use the first path as the "destination path" }
  WizardForm.DirEdit.Text := Page.Values[0];
  Result := True;
end;

procedure InitializeWizard;
begin
  Page := CreateInputDirPage(wpWelcome,
    'Destination', '',
    'Where should App be installed?',
    False, 'New Folder');

  Page.Add('App path');
  Page.Values[0] := WizardForm.DirEdit.Text;
 
  UsagePage := CreateInputOptionPage(wpWelcome,
    'Installation', 'choose component',
    'please choose one!:',
    False, False);
  UsagePage.Add('Component1');
  UsagePage.Add('Component2');

  Page.OnNextButtonClick := @InputDirPageNextButtonClick;
  Page := CreateInputDirPage(wpSelectDir,
    'Java path', '',
    'please specify Java Folder:', False, '');

  Page.Add('Java');

  Page.OnNextButtonClick := @InputDirPageNextButtonClick;
end;

Solution

  • If I understand your question: You are looking for a way to use a custom command-line parameter to populate the directory value on a custom directory page. Here's one way:

    [Code]
    var
      CustomPage: TInputDirWizardPage;
      CustomPath: string;
    
    function InitializeSetup(): Boolean;
    begin
      result := true;
      CustomPath := ExpandConstant('{param:CustomPath}');
    end;
    
    procedure InitializeWizard();
    begin
      CustomPage := CreateInputDirPage(wpSelectDir,
        'Select Custom Path',
        'What custom path do you want?',
        'Select a directory.',
        false,
        '');
      CustomPage.Add('Custom path:');
      CustomPage.Values[0] := CustomPath;
    end;
    

    With this in your [Code] section, running the setup program with a /CustomPath="directory name" parameter will set the value on the form to the parameter from the command line.