I have configured the below script to ask the user for an IP address as part of the install wizard, this address gets written to a config file which the application will reference to know where to communicate with. I would like to offer the opportunity to specify this IP address as a parameter in the command line as well so that deployment can be automated and performed silently.
From my research, it seems to be possible to add a command line parameter but I am struggling to understand exactly how to set this up within my Inno setup and then how I can make this optional to allow it to be specified on the command line or through the install wizard.
For example something like app1.exe /ipaddress 192.168.0.1
Apologies if this is an easy process, I am new to Inno Setup so any help would be appreciated.
Can anyone offer any assistance to help me get this setup?
[Code]
var
PrimaryServerPage: TInputQueryWizardPage;
function FileReplaceString(ReplaceString: string):boolean;
var
MyFile : TStrings;
MyText : string;
begin
Log('Replacing in file');
MyFile := TStringList.Create;
try
Result := true;
try
MyFile.LoadFromFile(ExpandConstant('{app}' + '\providers\win\config.conf'));
Log('File loaded');
MyText := MyFile.Text;
{ Only save if text has been changed. }
if StringChangeEx(
MyText, 'REPLACE_WITH_CUSTOMER_IP', ReplaceString, True) > 0 then
begin;
Log('IP address inserted');
MyFile.Text := MyText;
MyFile.SaveToFile(ExpandConstant('{app}' + '\providers\win\config.conf'));
Log('File saved');
end;
except
Result := false;
end;
finally
MyFile.Free;
end;
Result := True;
end;
procedure InitializeWizard;
begin
PrimaryServerPage :=
CreateInputQueryPage(
wpWelcome, 'Application Server Details', 'Where is installed?',
'Please specify the IP address or hostname of your ' +
'Primary Application Server, then click Next.');
PrimaryServerPage.Add('Primary Application Server IP/Hostname:', False);
end;
procedure ReplaceIPAddress;
begin
FileReplaceString(PrimaryServerPage.Values[0]);
end;