A Step-by-Step Guide to Transferring CustomActionData During WiX CustomAction Execution
A Step-by-Step Guide to Transferring CustomActionData During WiX CustomAction Execution
Inno SetupWiX ToolsetInstallShieldMSIX Packaging Tool
Check your inbox and confirm the
subscription
Exclusive Newsletter
Exclusive Newsletter
Get the latest WiX insights direct to your inbox. Subscribe now!
Disclaimer: This post includes affiliate links
If you click on a link and make a purchase, I may receive a commission at no extra cost to you.
How to pass CustomActionData to a CustomAction using WiX
Written by Horatiu Vladasel · September 9th, 2022
Do you want to transfer CustomActionData to a CustomAction in WiX? We’ll show you how in this article.
When adding CustomActions using WiX, there are two elements that you need to use:
- the CustomAction element;
- the Sequence element.
The CustomAction element specifies the custom action that will be added to the MSI CustomAction table.
On the other hand, the Sequence element is used to schedule the CustomAction within the corresponding table (AdminExecuteSequence, AdminUISequence, AdvertiseExecuteSequence, InstallExecuteSequence) and set any condition, if needed.
Each condition is evaluated separately, and the corresponding CustomAction is run only if the condition is set as True. Otherwise, the CustomAction gets skipped. If the condition syntax is invalid, then the sequence ends and returns iesBadActionData.
Get more details about WiX CustomActions from our How To Add Custom Actions in WiX Toolset article.
What is the challenge when you want to pass a property to a Deferred CustomAction?
A Deferred CustomAction doesn’t have any information about the original session handle and property data (Session.Property([PROPERTY])). This is because the script generated for it is executed outside of the installation process. Instead, you will need to use CustomActionData (Session.Property(“CustomActionData”)) .
How to use CustomActions with WiX?
Let’s suppose we need to add a script that takes the value of the SERVERPATH property as an input (passed to the installer via command line) and writes it into the registry. The CustomAction script should look like the one below:
First, we must define our CustomAction elements:
Copy
Let’s understand what SetServerPathProperty and SetServerPath CustomAction are:
- The SetServerPath CustomAction is the Deferred CustomAction and it references the VBScript defined above, which is stored in the Binary table.
- The SetServerPathProperty is the SetProperty CustomAction which is used to set the property of interest (SERVERPATH) property to a property with the same name as the Deferred CustomAction (SetServerPath).
We also need to define the Binary element because the VBScript referenced by the SetServerPath CustomAction is stored in the Binary table.
Copy
Once the CustomAction and Binary elements are defined, we can set the corresponding InstallExecuteSequence elements – one for each of the two CustomActions.
Copy
When scheduling the two CustomAction in the InstallExecuteSequence table, the SetProperty CustomAction (‘SetServerPathProperty) should be scheduled before the Deferred CustomAction (SetServerPath).
SetProperty CustomAction (‘SetServerPathProperty) is used to set the property of interest to a property with the same name as the Deferred CustomAction.
The complete listing for the WiX source file (.wxs) should look like the one below:
Copy
Now, all we need to do is to:
- Pre-process and compile the WiX source file into a WiX object file.
- Process the WiX object file compiled previously and build the Windows Installer (MSI package).
How to configure CustomActions with Advanced Installer?
If you use Advanced Installer to build and create your MSI, there is no need for an extra CustomAction to set the property of interest with the same name as the Deferred CustomAction.
All you need to do is specify the value of the CustomActionData property within the “ActionData” and Advanced Installer does the rest for you.
Have a look at our How to Use CustomActionData to Access Windows Installer Properties in Deferred CustomActions article to find out more about:- Why do you need CustomActionData- When can Deferred CustomActions go wrong- How you can pass CustomActionData to a CustomAction using Advanced Installer
Conclusion
WiX does not have a GUI and it builds the Windows Installer packages based solely on the information defined within the WiX source file (wxs). This makes it difficult to use, especially for people who have little or no experience.
On the other hand, Advanced Installer comes with a dedicated GUI for adding a CustomAction and passing the CustomActionData property to it which makes the job a lot easier and very intuitive.
Try out Advanced Installer’s dedicated GUI for CustomAction through our 30-day full feature trial .
Advanced Installer #1 alternative to the WiX Toolset
We decided to focus on our main goal to save precious time of our developers.
HANS-LEO TEULINGS
PHD – CEO, NEUROSCRIPT, LLC
You might find useful:
- CAB Embedding Options in MSI
- Updated installers in WiX Toolset
- Custom Actions In WiX Toolset
- Windows Services with WiX Installer
- Set WiX Installer Version to the Current Build Version
- Remove Files and Folders when Uninstalling with WiX
- How to set a WiX Toolset custom action to run only on uninstall
- How to create non-advertised shortcuts for all users / per machine with WiX Toolset
- How to Remove Files on Uninstall Using WiX Toolset
- How to create major upgrades for MSI packages using WiX Toolset
- How to pass CustomActionData to a CustomAction using WiX
- How to build an installer without a license page using WiX Toolset
- How to create a WiX KeyPath attribute
- How to Create a Desktop Shortcut using WiX Toolset
- How to Use WiX MSI to Update an Installed Application
- How to correctly set the install folder in Wix
- WiX Toolset Visual Studio Extension
- How to create a custom dialog in WiX for user input
- How to create an MSI installer with WiX
- How to use WIX MSI to do a silent install or uninstall of a web app
Get the most from packaging with Advanced Installer
Try the 30-day fully-featured edition absolutely free!
No credit card required
Also read:
- [New] Converting Multimedia Scripts Transitioning From XML/SSA to SRT
- [New] The Ultimate Adobe Premiere Soundtrack Guide
- [Updated] Acclaimed Melody Hub for Android Devices
- Customizing Windows 11 with Tailored Themes and Styles
- Download Windows 11 Insider Build 15031? Resolve 'Initializing' Issue for Smooth Installation
- Enabling RDC Access for Windows 11: Comprehensive Tutorial to Connect Remotely
- Enhance Your PC's Safety with Easy Restore Point Setup in Windows 11
- Expert Tips for Deleting Internet Trackers & Cookies in Google's Chrome Browser
- Fixes for Metro Exodus Game Crash Issues on Windows
- How to Change/Add Location Filters on Snapchat For your Motorola Moto G Stylus 5G (2023) | Dr.fone
- How to Configure Remote Desktop on Windows 11: A Step-by-Step Guide
- How to Enable and Create Restore Points in Windows 10?
- In 2024, Best 3 Software to Transfer Files to/from Your Huawei Nova Y71 via a USB Cable | Dr.fone
- In 2024, Transforming Your Videography From Monochrome to High-Dynamic Range Masterpieces
- New How to Record and Edit an Animoji or Memoji Karaoke Music Video for 2024
- Quick and Secure GeForce GTX 460 Drivers Downloading Guide for Windows Users
- Title: A Step-by-Step Guide to Transferring CustomActionData During WiX CustomAction Execution
- Author: Donald
- Created at : 2024-10-01 19:11:47
- Updated at : 2024-10-03 20:02:35
- Link: https://some-tips.techidaily.com/a-step-by-step-guide-to-transferring-customactiondata-during-wix-customaction-execution/
- License: This work is licensed under CC BY-NC-SA 4.0.