Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I log Inno Setup installations?

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 reports?

like image 259
sashoalm Avatar asked Feb 25 '11 10:02

sashoalm


2 Answers

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; 
like image 61
mirtheil Avatar answered Nov 20 '22 05:11

mirtheil


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; 
like image 16
JasonMcF Avatar answered Nov 20 '22 05:11

JasonMcF