Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

REG ADD a REG_MULTI_SZ Multi-Line Registry Value

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.

like image 609
Edwin Lee Avatar asked Dec 02 '22 01:12

Edwin Lee


1 Answers

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
like image 156
seth Avatar answered Dec 04 '22 06:12

seth