Menu

#1305 WriteRegMultiStr syntax giving unhelpful error

3.0 Series
open
nobody
None
5
2024-04-13
2024-02-15
No

I'm using NSIS 3.0.4.1

My nsh file contents:

!macro customInstall
  SetRegView 64
    /**
    * This hex string is myElectronApp.exe encoded in Regedit Version 5.0 format.
    * Refer to the instructions in the Registry tutorial
    */
   WriteRegMultiStr /REGEDIT5 HKLM "SOFTWARE\WOW6432Node\Key1\Key2" "Key3" 6d,79,45,6c,65,63,74,72,6f,6e,41,70,70,2e,65,78,65
!macroend

!macro customUnInstall
  SetRegView 64
    DeleteRegKey HKLM "SOFTWARE\WOW6432Node\Key1\Key2\Key3"
!macroend

It fails to compile with error:

Processing script file: "<stdin>" (ACP), then what's in the attached pic. As far as I can tell my syntax is exactly the same as what's in the docs.</stdin>

It seems to be complaining about the root_key, and the Usage seems to imply that the syntax should be HKLM64 instead of HKLM? But of course I tried that too and it doesn't work either.

Any idea what's wrong?
Thanks,

1 Attachments

Discussion

  • Jason

    Jason - 2024-02-16

    Turns out this is a documentation error. In the source code there is a comment that the end of the data must have 4 zero bytes at the end. Adding 4 zero bytes to your example makes it work.

    You can also look on msdn at the windows API version of this function for more information on the format required for the input.

     
  • Brent Thompson

    Brent Thompson - 2024-02-16

    That worked, thanks for the quick response. Working string:

    WriteRegMultiStr /REGEDIT5 HKLM "SOFTWARE\WOW6432Node\Key1\Key2" "Key3" 6d,79,45,6c,65,63,74,72,6f,6e,41,70,70,2e,65,78,65,00,00,00,00

    It also worked (compiled) with HKLM64

     

    Last edit: Brent Thompson 2024-02-16
  • Brent Thompson

    Brent Thompson - 2024-02-16

    For future searchers, I still had issues using the string above - I ended up with garbage in my registry entry. I was missing the info from here, specifically that characters have to be 2 bytes wide, so 6d becomes 6d,00.

     
  • Anders

    Anders - 2024-04-13

    When the documentation says it uses the .reg format, it really means it! The last 4 zero bytes are
    1. Required, they are the final string list termination marker and the byte values are written directly to the registry as is.
    2. The documentation clearly has 4 zero bytes at the end in its example.

    Could the error message be better? Perhaps.

     

Log in to post a comment.