Configuring Actions
Actions are configured on the Installer->Screens & Actions step. An action performs a configurable unit of work in the installer application.
Actions are attached to screens or they are part of the "Startup sequence" that allows you to perform actions before the installer or uninstaller is displayed. If any one of these actions fails and has a "Quit on failure" failure strategy, the installer application will not be shown.
Most often, actions are added to the "Installation" or "Uninstallation" screens. The advantage of those screens is that they have a progress bar and a status display that is utilized by actions. If a screen does not expose a progress interface, the status and progress messages of attached actions are lost. This is no problem for near-instantaneous actions such as setting an environment variable, but for time-consuming operations the user should be informed about progress, even if it is only an indeterminate progress bar. As an alternative to the "Installation" or "Uninstallation" screens, you can use "Display progress" screens to create additional installation phases.
Some actions have an "affinity" to a particular screen and will suggest to add themselves to that screen, such as the actions in the "Final options" category which would like to go to the "Finish" screen. However, this is only a suggestion to guide you for the most common use cases.
Some actions have an associated screen that allows the user to modify the behavior of the action. For example, the "Install a service" action has a corresponding "Services" screen where the user can decide whether the service should be installed and started when booting. If such a relationship exists, a corresponding notification is displayed after adding an action.
Properties of actions
Common properties of actions are:
Action elevation type [Privileges]
If the action should run in the elevated helper process.An elevated helper process is available on Windows and macOS if the process has been started without admin privileges and the "Request privileges" action has been configured to require full privileges.Condition expression [Control Flow]
This expression is evaluated to decide whether the action is executed. If the expression or script returns false, the current action will be skipped. This expression or script should not have any side-effects, it will be called while another screen is still being displayed.Rollback barrier [Control Flow]
If the action should be a rollback barrier. When a rollback barrier is completed, none of the preceding actions will be rolled back. You can use this property to prevent an incomplete rollback of complex changes or to protect actions from rollback when the user hits "Cancel" in the post-install phase.Exit code [Control Flow]
If the "Rollback barrier" property is selected, and a rollback terminates at this action, this property determines the exit code of the installer. By default, reaching a rollback barrier during a rollback is considered a success, but you can signal a failure by specifying a non-zero exit code here.This property is only visible if "Rollback barrier" is selected.
Can be executed multiple times [Control Flow]
If the action can be executed multiple times. If unselected, the action will only be executed once and do nothing for subsequent invocations of the containing screen. The default settings for screens ensure that a screen with actions that cannot be executed multiple times is only shown once. However, if the "Back button" property is changed of if you skip screens programmatically, a screen might be shown multiple times.Failure strategy [Error Handling]
If an action fails (i.e. returnsfalse
), the installer or uninstaller can continue, quit, or ask the user what to do. If you select something other than "Continue on failure", you should enter an error message in the "Error message" property unless the action displays the error itself.For "Return to the parent screen", no further actions will be executed and the previous screen will be displayed again. If the action is contained in the "Startup" node, the first screen will be shown and in unattended mode the application will quit.
Ask whether to retry the action
If the action fails, ask the user whether to retry the action.This is one button in a message dialog that shows the error message and the available options to react to the failure.
This property is only visible if "Failure strategy" is set to "Ask user".
Ask whether to quit
If the action fails, ask the user whether to quit the installer application.This is one button in a message dialog that shows the error message and the available options to react to the failure.
This property is only visible if "Failure strategy" is set to "Ask user".
Ask whether to ignore the failure
If the action fails, ask the user whether to ignore the failure and continue.This is one button in a message dialog that shows the error message and the available options to react to the failure.
This property is only visible if "Failure strategy" is set to "Ask user".
Error message [Error Handling]
If the action fails, this error message is displayed to the user. Otherwise the action fails silently.
Available actions
The following standard actions are available in install4j:
Category: Control
Change cancel button state
-splash
option has been passed on the command line and the simple unattended progress dialog with a cancel button is shown.
Run script
Set a variable
java.lang.Object
.
Set messages
Set the progress bar
Sleep
Category: Desktop integration
Add a desktop link
Add a startup executable on Windows and macOS
Add an executable to the dock
Create a Windows URL link
Create a file association
If the application has not yet been started, the arguments to the main method will contain the file name. Subsequent invocations can be intercepted with the com.install4j.api.launcher.StartupNotification
class. This action will be automatically reverted by the 'Uninstall files' action.
For macOS, file associations have to be defined on the "Executable info->macOS options" step of the launcher wizard.
Create program group
Create start menu entry
Register Add/Remove item
If this action runs with elevated privileges, the uninstaller will be started with elevated privileges by Windows and no unelevated actions can be performed. In the event that you need to execute processes without elevation, set the "Action elevation type" property to "Do not elevate". Note that the Add/Remove item will be registered for the current user only in that case.
This action will be automatically reverted by the 'Uninstall files' action.
Register a URL handler
On Windows and Linux, the arguments to the main method will contain the URL. On macOS, the arguments are available from the com.install4j.api.launcher.StartupNotification
class. If the "Allow only a single running instance of the application" check box is selected on the "Java invocation" step of the launcher wizard, subsequent invocations are intercepted by the com.install4j.api.launcher.StartupNotification
class on all platforms.
This action will be automatically reverted by the 'Uninstall files' action.
For macOS, URL handlers have to be defined on the "Executable info->macOS options" step of the launcher wizard.
Category: File operations
Change Windows file rights
If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
Copy files and directories
Create a symbolic link
Delete files and directories
Move files and directories
Set the UNIX access mode of files and directories
Set the modification time of files
Set the owner of files and directories
Category: Final options
Execute launcher
If the main installation process has been elevated by the "Request privileges" action, this action is pushed to the original process with limited rights. Please see the help topic on "Elevation Of Privileges" for more information.
Open PDF viewer
Reboot computer
Show URL
If the main installation process has been elevated by the "Request privileges" action, this action is pushed to the original process with limited rights. Please see the help topic on "Elevation Of Privileges" for more information.
Show file
If the main installation process has been elevated by the "Request privileges" action, this action is pushed to the original process with limited rights. Please see the help topic on "Elevation Of Privileges" for more information.
Category: HTTP and network
Add a Windows firewall rule
Download file
HTTP request
text
or containing "charset" information, the response body can be saved to an installer variable. To download large files, use the "Download file" action instead.The action will succeed if an HTTP response code in the 2xx range is received, otherwise it will fail. You can save the response code to a variable to inspect it in a later action.
Upload file
Wait for HTTP server
Wait for Socket
Category: JDBC
Check JDBC connection
Execute SQL query
java.util.List
with the row values. If the query is for a single column, the row value is the Java object representation of the return type, e.g. java.lang.String
for VARCHAR
or java.lang.Long
for INT
.
Execute SQL script
JDBC container action
Category: JSON files
Count occurrences in a JSON file
Modify JSON files
Read value from a JSON file
Category: Java preference store
Delete a node or key in the Java preference store
Load installer variables from the Java preference store
Read a key from the Java preference store
Save installer variables to the Java preference store
Set a key in the Java preference store
Category: Miscellaneous
Add VM options
.vmoptions
file or by changing the Info.plist file. This action will be automatically reverted by the 'Uninstall files' action.
Check for running processes
Modify an environment variable on Windows
Modify classpath
.vmoptions
file or by changing the Info.plist file. This action will be automatically reverted by the 'Uninstall files' action.
Request privileges
Please see the help topic on "Elevation Of Privileges" for a detailed discussion of this action.
Require installer privileges
Please see the help topic on "Elevation Of Privileges" for a detailed discussion of this action.
Run executable or batch file
Category: Persistence of installer variables
Create a response file
-varfile
command-line option.
Load a response file
Modify a response file
This action is useful for updating a response file from a custom installer application, where not all installer variables are available.
Category: Properties files
Read a properties file
java.util.Map
object with the properties to an installer variable. If you use a "Write properties to file" action to write the variable back to disk, the comments on the existing property definitions will be preserved.
Remove keys from properties file
Write properties to file
java.util.Map
object, another properties file or from direct entry.If the "Merge into existing file" property is selected, the new property definitions will be added to the existing ones.
Category: Services
Install a service
/etc/systemd/system
, otherwise a link will be placed in /etc/init.d
. On macOS, a LaunchDaemon will be created. This action will be automatically reverted by the 'Uninstall files' action.If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
Start a service
If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
Stop a service
If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
Category: Text files
Fix line feeds
Modify text files
Modify text files with regular expressions
Read text from file
String
.
Replace installer variables in text files
${installer:myVariable}
with their current values. The action also replaces i18n variables like ${i18n;myKey} and compiler variables like ${compiler:myCompilerVariable}
Write text to a file
Category: Update
Check for update
com.install4j.api.UpdateDescriptor
Schedule update installation
Shut down calling launcher
com.install4j.api.launcher.ApplicationLauncher
API.
Category: Windows registry
Change access rights for a key in the Windows registry
If a helper process with elevated privileges has been created by the "Request privileges" action, this action is pushed to the helper process. Please see the help topic on "Elevation Of Privileges" for more information.
Delete a key or value in the Windows registry
Read a value from the Windows registry
String, Integer, String[], byte[], WinRegistry.ExpandString
.
Set a value in the Windows registry
Category: XML files
Apply an XSLT transform
Count nodes in XML file
Insert XML fragment into XML files
Read value from XML file
Remove nodes from XML files
Replace text in XML files
Category: ZIP files and archives
Create a ZIP file
Extract a DMG file on macOS
Extract a TAR file
Extract a ZIP file
Install content of a ZIP file
Modify a ZIP file
Download and install component
Note: The "Install Files" action already downloads and installs all selected downloadable installation components. This action is intended for scenarios where an installation component has to be downloaded after the "Install files" action has run. For example, you could use this in a custom installer application to install optional files.
Execute previous uninstaller
Install files
Uninstall files