Innoscript using command line parameters

Innoscript

When we have an installer myinstaller.exe with custom command line parameters, e.g. myinstaller.exe /myparam=value, add this to the script wherever it is required.


ValueData: "{param:myparam|defvalue}";

There might be a more advanced scenario, when the parameter is not specified and we expect the user to enter it manually in a form


[Code]
var
  Page: TInputQueryWizardPage;
  MyParam: String;

function GetMyParam(Dummy: String): string;
begin
  Result := MyParam;
end;

procedure InitializeWizard();
begin
// Create the page
Page := CreateInputQueryPage(wpWelcome,
  'My Dialog', '',
  'Please specify myparam');

// Add items (False means it's not a password edit)
Page.Add('&MyParam:', False);

// Set initial values (optional)
Page.Values[0] := ExpandConstant('{param:myparam|}');

end;

procedure CurStepChanged(CurStep: TSetupStep);
begin
  if CurStep = ssInstall then begin
      // Read values into variables
    MyParam := Page.Values[0];
  end;
end;

function ShouldSkipPage(PageID: Integer): Boolean;
begin
  Result := False
  if PageID = Page.ID then
    if ExpandConstant('{param:myparam|}') = '' then
      Result := False;
    else
      Result := True
end;

Then use it in the the script as:


ValueData: "{code:GetMyParam|}";

Post a Comment

Previous Post Next Post