问题
I've made a installer via Inno Setup and now I'm need to restart computer after some files were run.
So, i have code:
....
[Files]
....
[Run]
Filename: firstfile
RESTART
Filename: secondfile
....
Is this possible? I have found one example script github, but i cant understand how to use this DetectAndInstallPrerequisites functions. If someone can advise or provide some simple example, I would be very gratefull
回答1:
Have a look at the CodePrepareToInstall.iss
example script included with Inno. It shows how to arrange for a reboot and have the installation automatically resume afterwards. (You may need to make further changes or save further values if your installation is more complex or prompts for further user input.)
The missing link in that example is that you need to fill in the DetectAndInstallPrerequisites
function by using ExtractTemporaryFile
to retrieve the appropriate files (as it runs before the main [Files]
section is processed) and Exec(ExpandConstant('{tmp}\yourfile.exe'), ...)
to actually run the file. If this is a subinstaller you can then check its exit code to determine if a reboot is actually required or not rather than unconditionally requesting a reboot.
Note that this code will be executed again following the reboot, so you also need some way to detect that the subinstall has succeeded and skip trying to run it again. Typically this is done by trying to detect the version of the installed subcomponent.
来源:https://stackoverflow.com/questions/19750880/inno-setup-restart-in-the-middle-of-setup-process