Windows – REG ADD a REG_MULTI_SZ Multi-Line Registry Value

command-lineregistrywindows

To add a REG_MULTI_SZ multi-line registry value, i can do

reg.exe ADD "HKLM\path\to\registry\key" /v RegistryValue /t REG_MULTI_SZ /d "abc\0def\0"

which would add ("abc", "def").

But what if i need to add ("abc", "", "def"), i.e. an empty item in between?

Doing

reg.exe ADD "HKLM\path\to\registry\key" /v RegistryValue /t REG_MULTI_SZ /d "abc\0\0def\0"

gives me an "invalid parameter" error.

Best Solution

This worked for me:

REG ADD "HKLM\LOCATION" /v "Value" /t REG_MULTI_SZ /d item1\0item2 /f

or if your items have whitespace:

REG ADD "HKLM\LOCATION" /v "Value" /t REG_MULTI_SZ /d "item1"\0"item2" /f

Make sure you don't have TWO trailing "\0" separators (one is OK, with or without the trailing \0 you will get your last return character) like the example below (like I saw in a TechNet article), or you will get an "ERROR: Invalid value specified for '/d'.":

REG ADD "HKLM\LOCATION" /v "Value" /t REG_MULTI_SZ /d item1\0item2\0\0 /f