首页 > 解决方案 > How to set a variable in INSTALL4j during the installation to make it available in the .exe file after installation

问题描述

I made using install4j IDE. During the installation, I want to be able to assign a variable and make it available for the .exe file when the installation is complete.

Simplified scenario:

  1. A user provides his name in the form while running the installer.
  2. Installation process finished.
  3. A user executes the created .exe file
  4. Application Greets the user with: Hello {name provided in step 1.}

What is the best way to achieve that?

标签: javainstallationinstall4j

解决方案


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

For example, if the configured variable is "myName", then in your launcher you can retrieve the entered value via

com.install4j.api.launcher.Variables.getInstallerVariable("myName")

For other installer variables that are not filled by form components, you can call

context.registerResponseFileVariable("otherVariable");

in a "Run script" action to make them available in the same way in your launchers.


推荐阅读