Search code examples
installation64-bitnsis

WriteRegStr HKLM: Cross Windows Platform Solution


On Windows 7/64 Bit Computers the NSIS function WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\" "blah" "blah" doesn't work.

From my understanding the only way to get it to work is to do this: WriteRegStr HKLM "Software\WOW6432Node\Microsoft\Windows\CurrentVersion\Uninstall\" "blah" "blah"

Am I correct that this is the only way to write to the Local Machine Registry on Windows 7/64 Bit Computers?

Is there a cross platform way/function that can write to the Local Machine Registry?

Is my only option something like this...

!macro WriteRegStrLocalMachine path regName regValue

    WriteRegStr HKLM "SOFTWARE\WOW6432Node\${path}" "${regName}" "${regValue}"
    WriteRegStr HKLM "SOFTWARE\${path}" "${regName}" "${regValue}"
!macroend

!macro ReadRegStrLocalMachine path regName regValue

    ReadRegStr $1 HKLM "SOFTWARE\WOW6432Node\${path}" "${regName}"
    ReadRegStr $2 HKLM "SOFTWARE\WOW6432Node\${path}" "${regName}"

    # TODO: Check if $1 or $2 contain data 
!macroend

Solution

  • Am I correct that this is the only way to write to the Local Machine Registry on Windows 7/64 Bit Computers?

    Wrong: with NSIS (that is a 32b application until a next release - the current being 2.46), you can choose to access either the 64b or the 32b by using SetRegView