Website Building » Wix » How Do I Use Custom Action on WiX?

How Do I Use Custom Action on WiX?

Last updated on October 1, 2022 @ 5:51 am

Custom actions in WiX allow you to execute code at various points during installation. There are several different types of custom actions, each with its own purpose and use case. In this article, we’ll go over the different types of custom actions and how to use them in your WiX projects.

Sequential Custom Actions

GREAT NEWS:

Exciting update! We've collaborated with Wix to offer WBI users with a free plan for all website creation needs - Explore the details here.

Sequential custom actions are the most basic type of custom action. They are executed in the order that they are defined in the WiX source file. Sequential custom actions can be used to launch executables, copy files, write to the registry, etc. Basically, anything that can be done from the command line can be done with a sequential custom action.

To define a sequential custom action, use the element.

The following example shows how to define a sequential custom action that launches an executable:

PRO TIP: If you are not comfortable working with code or are not a developer, we do not recommend using custom action on WiX. Custom action can be used to extend the functionality of your installer, but can also be difficult to troubleshoot if something goes wrong.

Conditional Custom Actions

Conditional custom actions are similar to sequential custom actions, but they are only executed if a condition is met. For example, you might want to conditionally launch an executable only if a certain file exists on the Target system. Or you might want to write to the registry only if the user is an administrator. Conditions can be anything that can be evaluated at install time.

To define a conditional custom action, use the element and specify a Condition attribute. The following example shows how to conditionally launch an executable only if the user is an administrator:

Immediate Custom Actions

Immediate custom actions are executed immediately after the installer initializes ( before any interfaces are displayed ). This type of custom action is typically used to perform validation or initial setup tasks that need to be done before installation begins. Immediate custom actions cannot display any user interface elements.

Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.