2011-02-25 196 views

回答

16

您可以設置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; 
+6

您是否真的認爲有必要爲每個設置步驟重複計算路徑和文件名稱?爲什麼不把它移入'if CurStep = ssDone then' block? – 2011-03-04 12:49:21

+6

+1 Mittheil!我已經使用過你的提示,但是改用DeinitializeSetup。然後,即使用戶在安裝任何東西之前退出安裝程序,也會複製日誌。 – Lars 2013-11-25 23:46:27

10

繼從拉斯評論我用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;