Search code examples
windowsregistryinno-setup

Inno Setup append rows in a multi-string key in registry


I need to add some rows in a multi-string value of PreshutdownOrder key of Windows registry.

How can I append rows to an existing value?


Solution

  • Add an entry to [Registry] section with ValueType parameter set to multisz. Use {olddata} and {break} tokens in the ValueData parameter:

    On a string, expandsz, or multisz type value, you may use a special constant called {olddata} in this parameter. {olddata} is replaced with the previous data of the registry value. The {olddata} constant can be useful if you need to append a string to an existing value, for example, {olddata};{app}. If the value does not exist or the existing value isn't a string type, the {olddata} constant is silently removed. {olddata} will also be silently removed if the value being created is a multisz type but the existing value is not a multi-string type (i.e. it's REG_SZ or REG_EXPAND_SZ), and vice versa.

    On a multisz type value, you may use a special constant called {break} in this parameter to embed line breaks (nulls).

    [Registry]
    Root: HKLM; Subkey: "SYSTEM\CurrentControlSet\Control"; ValueType: multisz; \
        ValueName: "PreshutdownOrder"; ValueData: "{olddata}{break}newline"