Inno Setup has command line parameter /LOG=\"filename\"
. Can I specify a log filename from inside the Inno Setup script, so I can include it later in my error r
You can set the SetupLogging
option (SetupLogging=yes
) then integrate the following code into your script to copy the log somewhere.
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;
Following the comment from Lars I used the DeinitializeSetup()
procedure, but I also changed the new file path to use the {src}
constant to copy the log file to the directory that the installer is run from instead of {app}
constant which may/may not be created if the user cancels the installation:
// 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;