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
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | yes | – | Full registry key path. Must start with HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, HKEY_USERS, or HKEY_CURRENT_CONFIG. |
name | string | no | – | Value name. Use null or empty string for the default value of the key. |
type | string | no | String | One of String, ExpandString, Binary, DWord, MultiString, QWord. |
value | string | no | – | The value. Format depends on type (see below). |
Value formats by type
type | Encoding |
|---|---|
String | A regular UTF-16 string. |
ExpandString | A 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". |
Binary | Hex-encoded bytes, e.g., "4d,79,41,70,70,6c,69,63,61,74,69,6f,6e". |
DWord | 32-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). |
QWord | 64-bit value as 16 hex digits. |
MultiString | A 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
.regfile. Ifregeditexports your value asdword:00003039, you write00003039.
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
| Aspect | MSI | MSIX |
|---|---|---|
| Writes to live registry | Yes. | No. Writes go into the MSIX package container's virtual hive. |
Visible in regedit | Yes (under the actual hive). | Only when running regedit from inside the package's view. |
Validation rules
| Validator | Catch |
|---|---|
required | key is mandatory. |
valid registry key | Must start with one of the five allowed hive prefixes. |
valid value | type must be one of the supported registry types. |
duplicate registry check | Two 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.