How can I log Inno Setup installations?

后端 未结 2 510
囚心锁ツ
囚心锁ツ 2020-12-23 17:34

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

相关标签:
2条回答
  • 2020-12-23 18:23

    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; 
    
    0 讨论(0)
  • 2020-12-23 18:29

    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; 
    
    0 讨论(0)
提交回复
热议问题