2
votes

I'm using the deleteafterinstall flag for some temporary files, but if they are still locked by a process at the time Inno Setup installer is finishing, will they be scheduled to be deleted later?

The documentation doesn't mention what happens in that case:

deleteafterinstall

Instructs Setup to install the file as usual, but then delete it once the installation is completed (or aborted). This can be useful for extracting temporary data needed by a program executed in the script's [Run] section.

This flag will not cause existing files that weren't replaced during installation to be deleted.

This flag cannot be combined with the isreadme, regserver, regtypelib, restartreplace, sharedfile, or uninsneveruninstall flags.

1
Did you try it out? InnoSetups help doesn't detail this, so I guess the usual Inno behaviour will kick in and an error message will be shown to the user. For example for resetreplace ( jrsoftware.org/ishelp/index.php?topic=filessection ), they can restart the computer, and detail this, so I guess they would detail a scheduled deletion in the manual too. But testing this out should be easy to do.Akku

1 Answers

1
votes

I'm not sure how much deep explanation you expect for the answer, but the best for this I think is to jump into the source code. So, all the files having the deleteafterinstall flag specified are added to the DeleteFilesAfterInstallList collection, which is iterated when the setup is being deinitialized. At that time, the collection is iterated file by file and for each file from that collection is called the DeleteFileRedir function, which optionally disables WOW64 redirection (not important for this case) and calls the Windows API function DeleteFile, which doesn't perform delayed deletion.