No. It's not possible. The log file name format for the SetupLogging
is hard-coded.
All you can do it to check in InitializeSetup
, if /LOG=
was specified on command-line and if not, re-spawn the installer with the /LOG=
.
Though it's somewhat an overkill.
function ShellExecute(hwnd: HWND; lpOperation: string; lpFile: string;
lpParameters: string; lpDirectory: string; nShowCmd: Integer): THandle;
external 'ShellExecuteW@shell32.dll 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
// This should not be needed since Inno Setup 6.2,
// see https://groups.google.com/g/innosetup/c/pDSbgD8nbxI
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;