Inno Setup:在设置过程中重新启动 [英] Inno Setup: restart in the middle of setup process

查看:192
本文介绍了Inno Setup:在设置过程中重新启动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经通过Inno Setup创建了一个安装程序,现在我需要在运行某些文件后重新启动计算机.

I've made a installer via Inno Setup and now I'm need to restart computer after some files were run.

所以,我有代码:

....
[Files]
....
[Run]
Filename: firstfile
RESTART
Filename: secondfile
....

这可能吗?我找到了一个示例脚本 github ,但是我不明白如何使用此DetectAndInstallPrerequisites函数. 如果有人可以提供建议或提供一些简单的例子,我将不胜感激

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

推荐答案

看看Inno随附的CodePrepareToInstall.iss示例脚本.它显示了如何安排重新引导以及如何在以后自动恢复安装. (如果您的安装更加复杂或提示用户进行进一步输入,则可能需要进行进一步的更改或保存其他值.)

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.)

该示例中缺少的链接是,您需要使用ExtractTemporaryFile来检索相应文件(在处理主[Files]部分之前运行)并使用Exec(ExpandConstant('{tmp}\yourfile.exe'), ...)来填充DetectAndInstallPrerequisites函数实际运行文件.如果这是子安装程序,则可以检查其退出代码以确定是否确实需要重新启动,而不是无条件地请求重新启动.

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.

这篇关于Inno Setup:在设置过程中重新启动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆