# Actions: Control

install4j BeanInfo catalog. Each entry below documents a bean class that can appear inside a `<serializedBean>` element in an install4j project file.

## Contents

- [Change cancel button state](#change-cancel-button-state) — `com.install4j.runtime.beans.actions.control.ChangeCancelButtonAction`
- [Run script](#run-script) — `com.install4j.runtime.beans.actions.control.RunScriptAction`
- [Set a variable](#set-a-variable) — `com.install4j.runtime.beans.actions.control.SetVariableAction`
- [Set installation directory](#set-installation-directory) — `com.install4j.runtime.beans.actions.control.SetInstallationDirectoryAction`
- [Set messages](#set-messages) — `com.install4j.runtime.beans.actions.control.SetMessageAction`
- [Set the progress bar](#set-the-progress-bar) — `com.install4j.runtime.beans.actions.control.SetProgressAction`
- [Sleep](#sleep) — `com.install4j.runtime.beans.actions.control.SleepAction`

---

### Change cancel button state
- **Class:** `com.install4j.runtime.beans.actions.control.ChangeCancelButtonAction`
- **Category:** Control
- **Multiple instances:** yes

Changes the visibility and the enabled state of the cancel button. This action works in GUI mode as well as in unattended mode when the -splash option has been passed on the command line and the simple unattended progress dialog with a cancel button is shown.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `buttonState` — Button state | [ButtonState](enums.md#buttonstate) | Configuration | — | The new button state for the cancel button. |

### Run script
- **Class:** `com.install4j.runtime.beans.actions.control.RunScriptAction`
- **Category:** Control
- **Multiple instances:** yes

Runs a custom script. The script must return a boolean value. If it returns false, the installation will be canceled.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `script` — Script | ScriptProperty → boolean | General | — | The script that will be executed. The script must return a boolean value. If it returns false, the installation will be canceled. |
| `rollbackScript` — Optional Rollback Script | ScriptProperty → void | General | — | The script that will be executed in case of a rollback. The return type is void. |

### Set a variable
- **Class:** `com.install4j.runtime.beans.actions.control.SetVariableAction`
- **Category:** Control
- **Multiple instances:** yes

Sets a variable by running a custom script. The script can return any java.lang.Object.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `script` — Script | ScriptProperty → Object | General | — | The script that will be executed. The script can return any java.lang.Object. |
| `variableName` — Variable name | String [context=variableName] | General | — | The name of the variable that will be set. Enter the variable without the installer prefix and the dollar sign. |
| `onlyIfUndefined` — Only if undefined | boolean | General | — | The variable will only be set if it was previously undefined. This is useful for variables that your user can pass via -V or -varfile at the command line. |
| `failIfNull` — Fail if value is null | boolean | General | — | If selected, the action will fail if a null value is returned from the script. |
| `responseFileVariable` — Register for response file | boolean | General | — | If selected, the variable will be saved to the response file .install4j/response.varfile that is created automatically when the installer exits.This is equivalent to calling context.registerResponseFileVariable(variableName) in a script.If the variable is present in the response file, the "Load response file" action in the startup node of the uninstaller will make this variable available in the uninstaller. |

### Set installation directory
- **Class:** `com.install4j.runtime.beans.actions.control.SetInstallationDirectoryAction`
- **Category:** Control
- **Multiple instances:** yes

Set the installation directory according to a selected installation scope.With the installation scope set to "For all users if full admin rights are available", this action can be placed after a "Request privileges" action to set the installation directory to a directory that is used by all users. When used together with the "Installation scope chooser" form component, the installation scope should be set to "According to the sys.installForAllUsers variable" to set the installation directory according to the user selection. This action sets the boolean installer variable "sys.installForAllUsers" with a value depending on the actual installation scope.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `installationScope` — Installation scope | [InstallationScope](enums.md#installationscope) | Configuration | — | The scope of the installation.For "For all users if directory is writable", the actual installation scope depends on whether the current process can write into the directory that is used for global installations. That condition can change if a "Request privileges" action is executed successfully. |
| `searchForPreviousInstallation` — Search for previous installation | boolean | Configuration | — | Search for a previous installation of this application according to the "Installation scope" property.The action can be configured to search additionally in other scopes with the "Always search for global installations" and "Always search for user-specific installations" properties |
| `includeAllUsers` — Always search for global installations | boolean | Configuration | `searchForPreviousInstallation`=true | In addition to the configured installation scope, search for a global installation. |
| `includeUserSpecific` — Always search for user-specific installations | boolean | Configuration | `searchForPreviousInstallation`=true | In addition to the configured installation scope, search for a user-specific installation. |
| `skipForCommandLineInstallationDirectory` — Skip for command line installation directory | boolean | Configuration | — | Skip this action, if the installation directory was set on the command line with the -dir parameter. |

### Set messages
- **Class:** `com.install4j.runtime.beans.actions.control.SetMessageAction`
- **Category:** Control
- **Multiple instances:** yes

Sets the messages in the progress interface.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `useStatus` — Use status | boolean | General | — | If the status message should be set. |
| `statusMessage` — Status message | String | General | `useStatus`=true | The status message. |
| `useDetail` — Use detail | boolean | General | — | If the detail message should be set. |
| `detailMessage` — Detail message | String | General | `useDetail`=true | The detail message. |

### Set the progress bar
- **Class:** `com.install4j.runtime.beans.actions.control.SetProgressAction`
- **Category:** Control
- **Multiple instances:** yes

Change the value of the progress bar or set it to indeterminate mode.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `progressChangeType` — Type of change | [ProgressChangeType](enums.md#progresschangetype) | Configuration | — | Change the progress bar either to a percentage value, add progress, set it to indeterminate mode, start a timer, or return from indeterminate mode and show the last percentage value. |
| `percentValue` — Percent value | int | Configuration | `progressChangeType` ∈ [Set percentage value, Add percentage value] | The progress value from 0 to 100. This property is only used when a percentage value is set or added. |
| `timerPeriod` — Timer period | int | Configuration | `progressChangeType`=Start a timer | The time in milliseconds for one percent. This property is only used when the timer is started. |
| `timerMaxPercentValue` — Timer maximum value | int | Configuration | `progressChangeType`=Start a timer | The maximum progress value to be set by the timer. This property is only used when the timer is started. |

### Sleep
- **Class:** `com.install4j.runtime.beans.actions.control.SleepAction`
- **Category:** Control
- **Multiple instances:** yes

Sleep a specified number of milliseconds. This is useful to ensure that a progress screen is displayed for at least a certain period of time.

| Property | Type | Category | Visible when | Description |
|---|---|---|---|---|
| `sleepTimeMs` — Sleep time | int | Configuration | — | The sleep time in milliseconds. |

