## Response files |

### 1. Introduction

With a response file you can change the default user selection in all screens. A response file is a text file with name value pairs that represent certain installer variables. All screens provided be install4j ensure that they write all user selections to appropriate installer variables and bind their user interface components to these variables. This includes form screens.

Installer variable values are of the general type `java.lang.Object`. In a response file, only variables with values of certain types are included: The default type is `java.lang.String`. In addition the types `java.lang.Boolean`, `java.lang.Integer`, `java.util.Date` `java.lang.String[]` and `int[]` are supported. In order to let the installer runtime know about these non-default types, the variable name in the response file is followed by a '$' sign and an encoding specifier like 'Integer' or 'Boolean'.

Response file variables are variables that have been registered with `context.registerResponseFileVariable(...)` in the installer. All variables that are bound to form components are automatically registered as response file variables. Also, system screens register response file variables as needed to capture user input.

All installer variables live in the same name space. If you use an installer variable more than once for different user inputs, the response file only captures the last user input and may lead to erroneous behavior when the installer is run with a response file. If you would like to optimize your installers for use with a response file, you have to make sure that the relevant variable names are unique within your installer.

A response file can be used to

- Configure the installer for unattended execution mode
- Change the default settings in the GUI and console installer
- Get additional debugging information for an installation

When applying a response file to an installer, all variable definitions are translated into installer variables. The response file shares the same mechanism with the variable file offered by the -varfile installer option. You can add the contents of a response file to a variable file and vice versa.

### 2. Generating response files

There are two ways to generate a response file:

- A response file is generated automatically after an installation is finished. The generated response file is found in the `.install4j` directory inside the installation directory and is named `response.varfile`. When you request debugging information from a user, you should request this file in addition to the installer log file.
- install4j offers a "Create a response file" action that allows you to save the reponse file to a different file in addition to the automatically generated response file. Here, you can also specify variables that you would not like to be included in the reponse file. Together with an appropriate form component on the "Additional confimations" screen you can query the user whether to create such a response file or not.

### 3. Applying response files

When an installer is executed, it checks whether a file with the same name and the extension .varfile can be found in the same directory and loads that file as the response file. For example, if an installer is called `hello_setup.exe` on Windows, the response file next to it has to be named `hello_setup.varfile`.

You can also specify a response file explicitly with the -varfile installer option.

Response files work with all three installer modes, GUI, console and unattended.

### 4. Response file variables

The variables that you see in the response file exist at runtime independently of the response file. You can use these installer variables to access or change user selections on system screens. For example, the "Create program group" screen on Windows binds the user selection for the check box that asks the user whether to create the program group for all users to the variable sys.programGroup.allUsers. To access the current user selection from somewhere else, you can use the expression

          context.getBooleanVariable("sys.programGroup.allUsers")

To change that selection, you can invoke

         context.setVariable("sys.programGroup.allUsers", Boolean.FALSE)