不,這是不可能的。 SetupLogging
的日誌文件名格式是硬編碼的。
如果在命令行中指定/LOG=
,並且如果不是,則使用/LOG=
重新生成安裝程序,所有您可以執行此操作來檢查InitializeSetup
。
雖然這有點過分。
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle;
external '[email protected] stdcall';
function InitializeSetup(): Boolean;
var
HasLog: Boolean;
Params: string;
I: Integer;
S: string;
RetVal: Integer;
begin
HasLog := False;
Params := '';
for I := 1 to ParamCount do
begin
S := ParamStr(I);
if CompareText(Copy(S, 1, 5), '/LOG=') = 0 then
begin
HasLog := True;
break;
end;
{ Do not pass our /SL5 switch }
if CompareText(Copy(S, 1, 5), '/SL5=') = 0 then
begin
Params := Params + AddQuotes(S) + ' ';
end;
end;
Result := True;
if HasLog then
begin
Log('Log specified, continuing.');
end
else
begin
{ add selected language, so that user is not prompted again }
Params := Params + ' /LANG=' + ActiveLanguage;
{ force logging }
Params := Params + ' /LOG="' + ExpandConstant('{%TEMP}\ProductInstall.log') + '"';
Log(Format('Log file not specified, restarting setup with [%s]', [Params]));
RetVal := ShellExecute(0, '', ExpandConstant('{srcexe}'), Params, '', SW_SHOW);
Log(Format('Restarting setup returned [%d]', [RetVal]));
if RetVal > 32 then
begin
Log('Restart with logging succeeded, aborting this instance');
Result := False;
end
else
begin
Log(Format('Restarting with logging failed [%s], keeping this instance', [
SysErrorMessage(RetVal)]));
end;
end;
end;
馬丁,感謝您確認我的懷疑,並提出瞭解決方法,雖然如您所說,這有點矯枉過正。我想我會在安裝結束時重命名該文件。 –