Inno Setup AfterInstall function called for each file

I want to call the function after installing the folder, but the InstallEnv function seems to be called several times, maybe there is a folder for each file (for confirmation). Is there a way to call it only once after it has installed all these files? I cannot use the Run section because I want to make a mistake with the return code.

 Source: "InputFiles\virtualenv-1.8.2\*"; DestDir: "{tmp}/virtualenv"; \ Flags: recursesubdirs; AfterInstall: InstallEnv; 
+6
source share
2 answers

Yes, it runs once for each file. reference says this (emphasized by me):

The BeforeInstall or AfterInstall function to write the [Files] section uses a wildcard once per file , matching the pattern. using CurrentFileName to check for which file the function is being called.

And no, there is no way to call it once after all the files are installed. If you intend to run it only once, this will not be a problem, since you can declare a flag variable indicating that the function has already been called, but you want to determine if it was the last call, and there is no workaround for this.

Well, maybe if you find out which file will be the last to be installed from this folder, you can check this for the result of CurrentFileName , but I doubt that you can determine which one will be installed last at compile time (since at runtime in There is currently no way to get a list of files to install).

+3
source

It is not possible to call it at the end of the installation of this group of files from a single entry. However, you can call the function at the appropriate time using a dummy entry:

 [Files] Source: "InputFiles\virtualenv-1.8.2\*"; DestDir: "{tmp}\virtualenv"; Flags: recursesubdirs Source: dummy.txt; DestDir: {tmp}; AfterInstall: InstallEnv 

The Source file must exist, but it can be a file with zero byte. Since the installation is located in {tmp} , it will be deleted after installation, so its contents do not matter.

This works because the [Files] entries are set in the specified order.

+5
source

Source: https://habr.com/ru/post/958937/


All Articles