Koenigsberg
Koenigsberg

Reputation: 1798

Calling WriteRegMultiStr in NSIS properly

With version 3.02 of NSIS came the addition of the WriteRegMultiStr function. When the function is called in my script the script throws an error:

Usage: WriteRegMultiStr /REGEDIT5 rootkey subkey entry_name hex_string_like_660000000000
root_key=(HKCR[32|64]|HKLM[32|64]|HKCU[32|64]|HKU|HKCC|HKDD|HKPD|SHCTX)

The call itself looks like this:

WriteRegMultiStr /REGEDIT5 HKLM "System\CurrentControlSet\Services\SomeService" "DependsOnService" "service1 service2"

Since there is no documentation on this specific function which was added later on, long after WriteRegStr and WriteRegDWORD were available, I have to wonder - how does one use it?

So far with respect to entering REG_MULTI_SZ values I only found the directive to use a registry-NSIS -plugin. Yet the function exists, so how can it be used?

Addendum:

Encoding the string to hex and passing it with ot without quotation marks yields no desirable result either.

Upvotes: 2

Views: 482

Answers (2)

Anders
Anders

Reputation: 101736

As you found out, the value data must be in the exact same format as .reg files from Windows 2000+.

The reason this instruction works this way is because it is actually the same as WriteRegBin under the hood and very little code was added to support this new functionality.

In the future you might be able to drop the /REGEDIT5 switch and give it plain strings but support for that has not been added yet.

The Registry plug-in does allow you to write these strings in a sane manner.

Upvotes: 1

Koenigsberg
Koenigsberg

Reputation: 1798

I was actually able to find an answer after digging through the depths of the internet. Since I don't think this has been answered on StackOverflow I will leave a response here, in case anyone wants to use this function.

The structure of the command as described in the opening post is basically correct, but the value must be encoded precisely. My command looks like this:

WriteRegMultiStr /REGEDIT5 HKLM "System\CurrentControlSet\Services\SomeService" "DependsOnService" 54,00,63,00,70,00,69,00,70,00,00,00,41,00,66,00,64

For anyone intending to test this string, this is

Tcpip
Afd

encoded in hexadecimal regedit format. Precisely this is Regedit Version 5.0 format, as opposed to REGEDIT4 format. A conversion editor can be used to achieve this, I used OTConvertIt.

The script should then compile, assuming you run NSIS version 3.02 or higher.

Upvotes: 1

Related Questions