Inno安装程序有命令行参数/LOG="filename"
。是否可以从Inno设置脚本中指定日志文件名,以便以后可以将其包含在错误报告中?
发布于 2011-02-25 22:19:47
您可以设置SetupLogging
选项(SetupLogging=yes
),然后将以下代码集成到脚本中,以便将日志复制到某个地方。
procedure CurStepChanged(CurStep: TSetupStep);
var
logfilepathname, logfilename, newfilepathname: string;
begin
logfilepathname := ExpandConstant('{log}');
logfilename := ExtractFileName(logfilepathname);
newfilepathname := ExpandConstant('{app}\') + logfilename;
if CurStep = ssDone then
begin
FileCopy(logfilepathname, newfilepathname, false);
end;
end;
发布于 2014-01-29 21:52:44
在Lars的评论之后,我使用了DeinitializeSetup()
过程,但我还更改了新的文件路径,使用{src}
常量将日志文件复制到运行安装程序的目录,而不是{app}
常量,如果用户取消安装,可能会/可能不会创建该常量:
// Called just before Setup terminates. Note that this function is called even if the user exits Setup before anything is installed.
procedure DeinitializeSetup();
var
logfilepathname, logfilename, newfilepathname: string;
begin
logfilepathname := ExpandConstant('{log}');
logfilename := ExtractFileName(logfilepathname);
// Set the new target path as the directory where the installer is being run from
newfilepathname := ExpandConstant('{src}\') + logfilename;
FileCopy(logfilepathname, newfilepathname, false);
end;
发布于 2021-04-22 18:43:50
从JasonMcF扩展示例...检查是否创建了卸载程序,以查看安装程序是否已成功完成。
// Called just before Setup terminates.
// Note that this function is called even if the user exits Setup before anything is installed.
procedure DeinitializeSetup();
var
unInstaller, logFilePath, logFileName, newFilePath: string;
begin
unInstaller := ExpandConstant('{uninstallexe}');
logFilePath := ExpandConstant('{log}');
logFileName := ExtractFileName(logFilePath);
if FileExists(unInstaller) then
begin
// uninstaller exists, setup was finished successfully, copy log to app directory
newFilePath := ExpandConstant('{app}\') + logFileName;
end
else
begin
// setup didn't finish successfully, copy log to src directory
newFilePath := ExpandConstant('{src}\') + logFileName;
end;
Log('DeinitializeSetup');
Log('- unInstaller:' + unInstaller);
Log('- logFilePath:' + logFilePath);
Log('- newFilePath:' + newFilePath);
FileCopy(logFilePath, newFilePath, false);
end;
https://stackoverflow.com/questions/5116217
复制相似问题