[Inno Setup] command line parameter

; Script generated by the Inno Setup Script Wizard.
; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES!

//cmd 창에서 setup.exe /myParam=”1111″ /silent

#define MyAppName “My Program”
#define MyAppVersion “1.5”
#define MyAppPublisher “My Company, Inc.”
#define MyAppURL “http://www.example.com/”
#define MyAppExeName “MyProg.exe”

[Setup]
; NOTE: The value of AppId uniquely identifies this application.
; Do not use the same AppId value in installers for other applications.
; (To generate a new GUID, click Tools | Generate GUID inside the IDE.)
AppId={{41ADC09E-257F-458A-84E5-54DAA83735AC}
AppName={#MyAppName}
AppVersion={#MyAppVersion}
;AppVerName={#MyAppName} {#MyAppVersion} – X
AppPublisher={#MyAppPublisher}
AppPublisherURL={#MyAppURL}
AppSupportURL={#MyAppURL}
AppUpdatesURL={#MyAppURL}
DefaultDirName={pf}\{#MyAppName}
DisableProgramGroupPage=yes
OutputBaseFilename=setup
Compression=lzma
SolidCompression=yes

 

[Tasks]
Name: “desktopicon”; Description: “{cm:CreateDesktopIcon}”; GroupDescription: “{cm:AdditionalIcons}”; Flags: unchecked

 

[Icons]
Name: “{commonprograms}\{#MyAppName}”; Filename: “{app}\{#MyAppExeName}”
Name: “{commondesktop}\{#MyAppName}”; Filename: “{app}\{#MyAppExeName}”; Tasks: desktopicon

//[Run]
//Filename: “{pf}\{#MyAppExeName}”; Parameters: {code:GetParams}

 

[Code]
var
ConfigPage: TInputQueryWizardPage;

function GetParams(Value: string): string;
begin
Result := ConfigPage.Values[0];
end;

function StringReplace(S, oldSubString, newSubString: String): String;
var
stringCopy: String;
begin
stringCopy := S; { Prevent modification to the original string }
StringChange(stringCopy, oldSubString, newSubString);
Result := stringCopy;
end;

function StartsWith(SubStr, S: String): Boolean;
begin
Result:= Pos(SubStr, S) = 1;
end;

function GetCommandlineParam(inParamName: String): String;
var
paramNameAndValue: String;
i: Integer;
begin
Result := ”;

for i := 0 to ParamCount do
begin
paramNameAndValue := ParamStr(i);
if (StartsWith(inParamName, paramNameAndValue)) then
begin
Result := StringReplace(paramNameAndValue, inParamName + ‘=’, ”);
break;
end;
end;
end;

procedure InitializeWizard;
begin
{ Create the page }
ConfigPage :=
CreateInputQueryPage(
wpWelcome, ‘User input’, ‘User input’,
‘Please specify the following information, then click Next.’);
{ Add items (False means it’s not a password edit) }
ConfigPage.Add(‘Input here:’, False);
{ Set initial values (optional) }
ConfigPage.Values[0] := GetCommandLineParam(‘/myParam’);//ExpandConstant(‘hello’);
end;