Inno Setup specify log name within the installer

Viewed 2175

Setting SetupLogging=yes creates the a file:

%TEMP%\Setup Log YYYY-MM-DD #NNN.txt

Is there any way to specify the name of the file? Note that I know I can rename it using FileCopy at the end of the installation (How can I log Inno Setup installations?), but I simply want to specify the name of the file at the outset, much like can be done with the switch /log=%TEMP%\ProductInstall.log. Is this possible?

2 Answers

Here's what I came up with to rename the log after setup completes. This is a bit tricky because you can't rename it while Inno Setup's still using it, but using start and timeout I was able to spin off a separate cmd process that waits a second, then does the rename.

[Run]
; Rename the log file to My_setup_log.txt.
Filename: "{cmd}"; WorkingDir: "{%TEMP}"; Parameters: "/d /c start "" "" /b cmd /d /c ""timeout 1 >NUL & del My_setup_log.txt 2>NUL & ren """"""{log}"""""" My_setup_log.txt"""; Flags: runhidden

As you can see, getting the proper number of quotes to surround the filenames in the quoted cmd argument requires six quotes in the Inno Setup command. If you want spaces in your renamed log file, put the six quotes on either side of it too. Yes, this would mean the string will end with nine consecutive quote marks!

Related