Website Building » Wix » How Do I Add a Custom Action to WiX Installer?

How Do I Add a Custom Action to WiX Installer?

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

Adding a custom action to a WiX installer can be done in a few different ways. The most common way is to use the CustomAction element.

This element defines the action that will be taken and the conditions under which it will be taken. For example, the following CustomAction will run a program called “MyProgram.exe” after the files have been installed:

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.

There are a few other things that can be defined in the CustomAction element, but these are the most important. The Id attribute is required and must be unique within the installer.

The FileKey attribute is required and must point to the program that will be run. The Execute attribute defines when the action will be taken and the Impersonate attribute defines whether or not to run the program as the installing user.

PRO TIP: Warning: Please be aware that adding a custom action to a WiX installer can be a complex process. If you are not familiar with WiX or do not have experience creating custom actions, we recommend that you seek out professional help to avoid potential problems.

Another way to add a custom action to a WiX installer is to use a DTF Custom Action. DTF custom actions are written in managed code and are compiled into a DLL.

They have access to all of the installer’s internals, so they are much more powerful than EXE custom actions. However, they are also much more difficult to write. For more information on DTF custom actions, see the WiX documentation.

Conclusion:


Adding a custom action to WiX is simple and only requires a few lines of code. There are two ways to do it: by using the CustomAction element or by using a DTF Custom Action.

Drew Clemente

Drew Clemente

Devops & Sysadmin engineer. I basically build infrastructure online.