Skip to main content

Registry

Write Windows registry keys and values during install.

Applies to: MSI and MSIX.

MSIX writes are virtualized. They go into the MSIX package's private registry view, not the live system hive. MSI writes go to the live registry.


Properties

PropertyTypeRequiredDefaultDescription
keystringyesFull registry key path. Must start with HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, or HKEY_CURRENT_CONFIG.
namestringnoValue name. Use null or empty string for the default value of the key.
typestringnoStringOne of String, ExpandString, Binary, DWord, MultiString, QWord.
valuestringnoThe value. Format depends on type (see below).

Value formats by type

typeEncoding
StringA regular UTF-16 string.
ExpandStringA binary value containing environment variables to be expanded at read time, e.g., "25,00,50,00,52,00,4f,00,47,00,52,00,41,00,4d,00,46,00,49,00,4c,00,45,00,53,00,25,00,5c,00,4d,00,79,00,20,00,41,00,70,00,70,00,6c,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,00,00".
BinaryHex-encoded bytes, e.g., "4d,79,41,70,70,6c,69,63,61,74,69,6f,6e".
DWord32-bit value as 8 hex digits (no 0x). To store decimal 12345 write "00003039" (the same way it appears in .reg exports as dword:00003039).
QWord64-bit value as 16 hex digits.
MultiStringA binary value containing multiple strings, e.g., "4d,00,79,00,00,00,41,00,70,00,70,00,6c,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00"

Source of the rule: Registry values for non-string types follow the same format as in the output of a Windows .reg file. If regedit exports your value as dword:00003039, you write 00003039.


Default value of a key (the (Default) entry)

To create or set the default value of a key, omit name or set it to null / "":

{
"key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"value": "Default value here"
}

Examples

A typical app config block

"registries": [
{ "key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"value": "My Application" },

{ "key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "InstallPath",
"type": "ExpandString",
"value": "25,00,50,00,52,00,4f,00,47,00,52,00,41,00,4d,00,46,00,49,00,4c,00,45,00,53,00,25,00,5c,00,4d,00,79,00,20,00,41,00,70,00,70,00,6c,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,00,00" },

{ "key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "Version",
"type": "String",
"value": "$.version" },

{ "key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "Telemetry",
"type": "DWord",
"value": "00000000" },

{ "key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "TraceLevel",
"type": "DWord",
"value": "00000003" }
]

Per-user setting (HKCU)

{
"key": "HKEY_CURRENT_USER\\SOFTWARE\\My Application",
"name": "Theme",
"type": "String",
"value": "Light"
}

A multi-string value

{
"key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "Plugins",
"type": "MultiString",
"value": "4d,00,79,00,00,00,41,00,70,00,70,00,6c,00,69,00,63,00,61,00,74,00,69,00,6f,00,6e,00,00,00,00,00"
}

The \u0000 is the JSON escape for the null character that delimits MultiString entries.

A binary value

{
"key": "HKEY_LOCAL_MACHINE\\SOFTWARE\\My Application",
"name": "Magic",
"type": "Binary",
"value": "4d,79,41,70,70,6c,69,63,61,74,69,6f,6e"
}

MSI vs MSIX behavior

AspectMSIMSIX
Writes to live registryYes.No. Writes go into the MSIX package container's virtual hive.
Visible in regeditYes (under the actual hive).Only when running regedit from inside the package's view.

Validation rules

ValidatorCatch
requiredkey is mandatory.
valid registry keyMust start with one of the five allowed hive prefixes.
valid valuetype must be one of the supported registry types.
duplicate registry checkTwo entries with the same key + name combination is an error.

You will also see warnings if you write to HKEY_LOCAL_MACHINE outside the recommended HKEY_LOCAL_MACHINE\SOFTWARE and HKEY_LOCAL_MACHINE\SYSTEM keys – Windows packaging best practices want apps to stay in the SOFTWARE hive.