我已经配置了下面的脚本来要求用户输入IP地址作为安装向导的一部分,该地址被写入应用程序将引用的配置文件以知道在哪里进行通信用。 不过目前,服务是在更新配置文件之前创建的(Run
部分发生在CurStep = ssPostInstall
之前),所以默认值在文件更新之前已经从文件中读取。 这意味着当前需要进一步的手动服务重启才能使应用程序进行通信。在创建服务之前运行post安装文件替换
据我所知,Run
部分可能在ssPostInstall
之后发生。
我已阅读文章Inno Setup: How to run a code procedure in Run section or before Run section?,这表明我可以使用参数BeforeInstall:
作为运行命令的一部分,以首先执行CurStepChanged
过程。但是,这会导致错误
找到了必需的函数或过程'CurStepChanged',但找不到兼容的原型。
我也试着移动CurStepChanged
部分上方的运行行和命令(尽可能匹配提到的文章),但是这仍然返回相同的错误。
任何人都可以提供一些指导,以我哪里出错配置?
[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\print\win\print-provider.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\print\win\print-provider.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 CurStepChanged(CurStep: TSetupStep);
begin
if CurStep = ssPostInstall then
begin
Log('File installed, replacing IP address');
FileReplaceString(PrimaryServerPage.Values[0]);
end;
end;
[run]
Filename: {sys}\sc.exe; Parameters: "create PCPrintProvider start= auto binPath= ""{app}\providers\print\win\pc-print.exe PCPrintProvider"" depend= Spooler" ; Flags: runhidden ; BeforeInstall: CurStepChanged
Filename: {sys}\sc.exe; Parameters: "start PCPrintProvider" ; Flags: runhidden ; BeforeInstall: CurStepChanged
你有没有尝试使用** **检查PARAM在[运行]部分? –