## Installer Modes |

### 1. Introduction

Installers generated by install4j can be run in three modes:

- GUI mode
  The default mode for installer and uninstaller executables is to display a GUI installer or uninstaller.
- Console mode
  If the installer is invoked with the `-c` argument, the interaction with the user is performed in the terminal from which the installer was invoked. The same applies to the uninstaller.
- Unattended mode
  If the installer is invoked with the `-q` argument, there is no interaction with the user, the installation is performed automatically with the default values. The same applies to the uninstaller.

The screen flow and the action sequence is executed in the same way for all three modes. If some actions or screens should not be traversed for console or unattended installations, you can use the methods `context.isConsole()` and `context.isUnattended()` in their "Condition expression" properties.

Also see the command line options reference for installers.

### 2. Console mode

Installers generated by install4j can perform console installations, unless this feature has been disabled in the application configuration of the Installer step. In order to start a console installation, the installer has to be invoked with the `-c` argument.

All standard screens in install4j present their information on the console and allow the user to enter all information as in the GUI installer. Not all messages in the GUI installer are displayed to the console installer, for each screen the subtitle is displayed as the first message. All standard screens in install4j have a question as their subtitle, if you add customizable screens to the screen sequence, you should phrase their subtitles as questions in order to create a consistent user experience for the console installer.

Also, form screens are fully mapped to console installers, each form component is displayed on the console, form components that expect user input will allow the users to modify or enter values.

On Microsoft Windows the information of whether an executable is a GUI executable or a console executable has to be statically compiled into the executable. Installers are GUI executables, otherwise a console would be displayed when starting the installer from the explorer. This is also the reason why the JRE supplies both the `java.exe` (console) and the `javaw.exe` (GUI) on Windows.

Since Windows XP there is a way for a GUI executable to attach to a console from which it was started. GUI executables are started in the background by default, therefore you have to use the start command like this to start it in the foreground and be able to enter information:

            start /wait installer.exe -c

On older Windows versions a new console is opened.

If you develop new screens or form components, you have to override the method

            boolean handleConsole(Console console) throws UserCanceledException

Displaying default data on the console and requesting user input is made easy with the `Console` class that is passed as a parameter.

### 3. Unattended mode

Installers generated by install4j can perform unattended installations, unless this feature has been disabled on the application configuration of the Installer step. In order to start an unattended installation, the installer has to be invoked with the `-q` argument. The installer will perform the installation as if the user had accepted all default settings.

There is no user interaction on the terminal. In all cases, where the installer would have asked the user whether to overwrite an existing file, the installer will not overwrite it. You can change this behavior by passing `-overwrite` as a parameter to the installer. In this case, the installer will overwrite such files. For the standard case, it is recommended to fine-tune the overwrite policy in the distribution tree instead, so that this situation never arises.

The installer will install the application to the default installation directory, unless you pass the `-dir` parameter to the installer. The parameter after `-dir` must be the desired installation directory. Example:

          installer.exe -q -dir "d:\myapps\My Application"

For the unattended mode of an installer, response files are an important instrument to pre-define user input.

On Windows, the output of the installer is not printed to the command line for unattended installation. If you pass the `-console` parameter after the `-q` parameter, a console will be allocated the displays the output to the user. This is useful for debugging purposes.

If the installation was successful, the exit code of the installer will be `0`, if no suitable JRE could be found it will be `83`, for other types of failure it will be `1`.

If you develop new screens or form components, you have to override the method

            boolean handleUnattended()

in order to support unattended installations.