Delete log file after successful install/uninstall

328 views
Skip to first unread message

Sam Oxigen

unread,
Jan 24, 2022, 2:09:20 PM1/24/22
to innosetup
I do log number of task outcomes to inno installer/uninstaller log file and I keep this file for review in case of errors. I try to delete this file if there is no error after install or uninstall.  I try to delete this file in [DeinitializeSetup] or [DeinitializeUninstall] events when install or uninstall respectively. However, DeleteFile returns 0; log file deletion fails. Is there a right place or way of deleting this file (after successful end)? Thanks in advance.

Gavin Lambert

unread,
Jan 24, 2022, 5:06:21 PM1/24/22
to inno...@googlegroups.com
On 25/01/2022 08:09, Sam Oxigen wrote:
> I do log number of task outcomes to inno installer/uninstaller log file
> and I keep this file for review in case of errors. I try to _delete this
> file if there is no error _after install or uninstall.  I try to delete
> this file in *[DeinitializeSetup]* or *[DeinitializeUninstall]* events
> when install or uninstall respectively. However, /DeleteFile/ returns 0;
> log file deletion fails. Is there a right place or way of deleting this
> file (after successful end)? Thanks in advance.

No, the log file is opened by the installer itself and it still has
things to write into it even after the last [Code] path. Further, if
someone has requested a log then they'll want to look at it after the
installer exits, successful or otherwise. So deleting it makes no sense.

It's also not typically needed; by default the log file is written into
the user's Temp folder so it will usually be deleted eventually on its
own by the normal disk cleanup processes.

Sam Oxigen

unread,
Jan 24, 2022, 11:59:55 PM1/24/22
to innosetup
ok. I'll try to explain this my managers.
I do separate logs for other tasks through other processes during setup (c++ .net host wrapper for c#, PowerShell port registration etc.) to another folder created under TEMP folder, that I eventually delete after successful install/uninstall/update where I, BTW, copy the inno log file too. So, I guess, I have to leave the original inno setup log file alone, since that  file cannot be deleted "by design."

Thanks for clarification.

Sam 

Gavin Lambert

unread,
Jan 25, 2022, 12:18:37 AM1/25/22
to inno...@googlegroups.com
On 25/01/2022 17:59, Sam Oxigen wrote:
> ok. I'll try to explain this my managers.
> I do separate logs for other tasks through other processes during setup
> (c++ .net host wrapper for c#, PowerShell port registration etc.) to
> another folder created under TEMP folder, that I eventually delete after
> successful install/uninstall/update where I, BTW, copy the inno log file
> too. So, I guess, I have to leave the original inno setup log file
> alone, since that  file cannot be deleted "by design."

It's not really a great idea to delete any logs.

Even if the installer thinks it succeeds overall, there may be some
issue that didn't quite work, and the user will contact your support
team, who will likely want to see logs that might help clarify things.

And even if it really did completely succeed, sometimes that in itself
can be useful information when the user is experiencing an issue, and
you can have a higher confidence in that if you have logs that
explicitly show success than if you have nothing.
Reply all
Reply to author
Forward
0 new messages