Skip to main content

Custom Actions

The customActions object is a container for six different kinds of custom actions:

"msi": {
"customActions": {
"exe": [], // run an executable
"dll": [], // call a function in a DLL
"registerDll": [], // regsvr32 a DLL
"powershell": [], // run a .ps1 script (embedded into MSI)
"installDriver": [], // install a driver from .inf
"setProperty": [] // set an MSI property at runtime ★ NEW in 2.2.0
}
}

Common properties

All custom-action types share these common properties:

PropertyTypeRequiredDefaultDescription
namestringyesUnique name within the package.
conditionstringnoMSI conditional expression that gates the action.
sequencestringnoEndOfExecutionStartOfExecution, EndOfExecution, or any short int (-32768 to 32767).
continueOnErrorbooleannofalseIf true, install proceeds when the action errors.

Common conditions

GoalCondition
Alwaysnull
Only during installNOT Installed
Only during repairInstalled AND NOT REMOVE
Only during uninstallREMOVE~="ALL"
Only during Windows 11(VersionNT = 1100 AND MsiNTProductType = 1)
Only during x64 OSVersionNT64
Only during x86 OSNOT VersionNT64

Full grammar: Microsoft's Conditional Statement Syntax.


exe – run an executable

PropertyTypeRequiredDescription
namestringyesAction name.
filePathstringyesPath to the executable. Validated as a syntactically valid path. Can be a path inside the package.
argumentsstringnoArguments.
condition, sequence, continueOnErrornoSee common.
{
"exe": [
{
"name": "PostInstallSetup",
"filePath": "$.installDir\\My Application.Setup.exe",
"arguments": "--silent --first-run --language [LANGUAGE]",
"condition": "NOT Installed",
"sequence": "EndOfExecution"
}
]
}

dll – call a function in a DLL

PropertyTypeRequiredDescription
namestringyesAction name.
filePathstringyesPath on disk at build time to the DLL (its bytes are embedded into the MSI).
entryPointstringnoName of the exported function to call.
argumentsstringnoArguments.
condition, sequence, continueOnErrornoSee common.
{
"dll": [
{
"name": "My ApplicationPostInstall",
"filePath": "ca\\My Application.CustomActions.dll",
"entryPoint": "PostInstall"
}
]
}

registerDllregsvr32 a DLL

PropertyTypeRequiredDefaultDescription
filePathstringyesDLL inside the package (validated against fileSystemEntries).
unregisterOnUninstallbooleannotrueWhether to regsvr32 /u on uninstall.
{
"registerDll": [
{ "filePath": "$.installDir\\My CompanyShellExt.dll" }
]
}

powershell – run a .ps1 script

PropertyTypeRequiredDescription
filePathstringyesPath on disk at build time to the .ps1 (its content is embedded into the MSI).
condition, sequence, continueOnErrornoSee common.
{
"powershell": [
{
"filePath": "ca\\InitializeDatabase.ps1",
"condition": "NOT Installed",
"sequence": "EndOfExecution"
}
]
}

installDriver – install a driver from .inf

PropertyTypeRequiredDefaultDescription
filePathstringyes.inf path inside the package.
importCertificatebooleannofalseImport the driver's signing certificate to TrustedPublishers before install.
removeOnUninstallbooleannotrueUninstall the driver when the package is uninstalled.
{
"installDriver": [
{
"filePath": "$.installDir\\drivers\\My CompanyUSB.inf",
"importCertificate": true
}
]
}

setProperty – set an MSI property at runtime ★ NEW in 2.2.0

Use this to compute a property value conditionally during install. It is the safe modern way to gate other custom actions.

PropertyTypeRequiredDefaultDescription
propertyNamestringyesProperty name to set.
propertyValuestringyesValue to set (supports [Property] substitution).
condition, sequence, continueOnErrornoDefault sequence is StartOfExecution.
{
"setProperty": [
{
"propertyName": "INSTALL_TIER",
"propertyValue": "Enterprise",
"condition": "Privileged"
},
{
"propertyName": "INSTALL_TIER",
"propertyValue": "Standard",
"condition": "NOT Privileged"
}
]
}

Validation

  • unique custom action name – every name across exe, dll, powershell must be unique.