【发布时间】:2020-04-09 13:35:06
【问题描述】:
作为安装向导的一部分,我已经配置了以下脚本以询问用户 IP 地址,该地址被写入配置文件,应用程序将参考该配置文件以了解与何处通信。我也想提供机会将此 IP 地址指定为命令行中的参数,以便可以自动进行部署并静默执行。
从我的研究来看,似乎可以添加一个命令行参数,但我很难准确理解如何在我的 Inno 设置中进行设置,然后我如何使这个可选以允许在命令行或通过安装向导。
例如像app1.exe /ipaddress 192.168.0.1这样的东西
抱歉,如果这是一个简单的过程,我是 Inno 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;
【问题讨论】:
标签: inno-setup