Unable to set Binary value in windows registry

Answered

Comments

1 comment

  • Avatar
    wojciechka

    The value for REG_BINARY is expected to be in binary form already.

    In general, it is recommended to simply ship a .reg file and simply run reg import command. For example it is possible to ship registry.reg as one of the files - such as:

    Windows Registry Editor Version 5.00

    [HHKEY_LOCAL_MACHINE\SOFTWARE\TEST\KEYNAME] "TestBinaryValue"=hex:01

    And then run reg command:

    <runProgram>
        <program>reg</program>
        <programArguments>import "${installdir.dos}\registry.reg"</programArguments>
    </runProgram>
    

    However, in this case it is also possible to use <decodeBase64> action to decode a binary 1 value (binary 0 value is AA== when base64-encoded):

    <decodeBase64>
        <text>AQ==</text>
        <variable>regvalue</variable>
    </decodeBase64>
    <registrySet>
        <key>HKEY_LOCAL_MACHINE\SOFTWARE\TEST\KEYNAME</key>
        <name>TestBinaryValue</name>
        <type>REG_BINARY</type>
        <value>${regvalue}</value>
        <wowMode>64</wowMode>
    </registrySet>
    

Please sign in to leave a comment.