如何在安装过程中在INSTALL4j中设置一个变量,使其在安装后在.exe文件中可用

How to set a variable in INSTALL4j during the installation to make it available in the .exe file after installation

我使用 install4j IDE 制作。在安装过程中,我希望能够分配一个变量并在安装完成后使其可用于 .exe 文件。

简化场景:

  1. 用户在表单中提供他的姓名,而 运行 安装程序。
  2. 安装过程完成。
  3. 用户执行创建的.exe文件
  4. 应用程序用以下方式问候用户:Hello {name provided in step 1.}

实现该目标的最佳方法是什么?

全部form components that take user input, for example the "Text field" form component bind the input to an installer variable that is automatically registered as a response file variable.

例如,如果配置的变量是 "myName",那么在您的启动器中您可以通过

检索输入的值
com.install4j.api.launcher.Variables.getInstallerVariable("myName")

对于表单组件没有填写的其他安装程序变量,可以调用

context.registerResponseFileVariable("otherVariable");

在 "Run script" 操作中以相同的方式在您的启动器中使用它们。