Inno Setup:安装过程完成后执行 command/batch 文件

Inno Setup : execute command/batch file after install process is complete

朋友们,我正在编写一个可以做很多事情的脚本 - 安装我的应用程序 + 其他开源软件,将 s/w 设置为服务,执行批处理文件来做一些事情等等。

  1. 我一开始设置了一些环境变量。在 Inno 脚本完成执行(即安装完成)之前,它们当然不会生效。
  2. 安装服务需要环境变量。
  3. 安装、配置和启动服务的命令在批处理文件中,我需要在安装完成后执行。我只需要执行一次这个批处理文件。

安装完成后如何使用 Inno 执行这个批处理文件?它可以在用户完成安装过程后立即发生,也可以在系统重启时 运行 发生一次。可以通过Inno脚本实现吗?

或者有没有办法让我的环境变量生效,让我的批处理文件可以运行?

我知道有些安装程序会在用户完成安装过程并且系统重新启动后执行部分安装。 Inno 是否支持这种功能?

我不确定 CurStepChanged + ssPostInstall 方法是否可以在这里工作,因为它基本上与 Inno 开始使用的环境相同,我的变量尚未生效。

如果这无法通过 Inno 脚本实现,我将在系统启动时放置批处理文件 - 在这种情况下,我将需要检查服务是否已经 installed/running 并采取适当的措施。但这会很粗糙。

请帮忙解决任何问题pointers/suggestions。

谢谢。

要安排批处理文件在下一个 Windows 运行 start/logon,向 HKCU\Software\Microsoft\Windows\CurrentVersion\RunOnce 键添加一个值:

[Registry]
Root: HKCU; Subkey: "Software\Microsoft\Windows\CurrentVersion\RunOnce"; \
    ValueType: string; ValueName: "MyProg"; ValueData: """{app}\MyBatch.bat"""

当 program/batch 为 运行 时,RunOnce 键中的值被 Windows 自动删除。

了解 Run and RunOnce Registry Keys

By default, the value of a RunOnce key is deleted before the command line is run. You can prefix a RunOnce value name with an exclamation point (!) to defer deletion of the value until after the command runs. Without the exclamation point prefix, if the RunOnce operation fails the associated program will not be asked to run the next time you start the computer.

执行顺序:

If more than one program is registered under any particular key, the order in which those programs run is indeterminate.

实际上程序 运行 是并行的。一些条目很容易成为 运行 直到 Windows 会话结束的应用程序。所以 Windows 不能等程序完成再开始另一个程序。

如果您需要 运行 特定顺序的批处理文件,只需创建一个指向主批处理文件的条目,该主批处理文件 运行 按您需要的顺序提供其他批处理文件。