Input serial number when running silent installati

2019-08-05 09:26发布

问题:

Is there any way to let the user enter the serial key for the product when running the (Innosetup) product installer with flags /SP- /SILENT /SUPPRESSMSGBOXES?

回答1:

You can create new command line parameter and pass the serial number in it.

/SERIAL=12345679

If this parameter is missing then do not allow to continue (show error/correct usage or simply terminate installation).



回答2:

To expand on @Slappy's answer:

You can use a /SERIAL= command line parameter, but InnoSetup doesn't support this as one of its standard command line parameters, so you'll have to do a bit of Pascal scripting. Something like the following should work.

procedure CheckForCommandLineSerial();
var
  i: Integer;
begin
  for i := 1 to ParamCount do
  begin
    if (Pos('/serial=', Lowercase(ParamStr(i))) = 1) and (Length(ParamStr(i)) > 8) then
    begin
      WizardForm.UserInfoSerialEdit.Text := Copy(ParamStr(i), 9, Length(ParamStr(i)) - 8);
      exit;
    end
  end;
end;

You can call this from your InitializeWizard event function.