dc_dweller
25th May 2011 19:21 UTC
Wow6432Node Issue
Hi all,
My installer is supposed to write something to HKEY_LOCAL_MACHINE\Software\... if this is a 32-bit Windows, and to HKEY_LOCAL_MACHINE\Software\Wow6432Node\... if it is a 64-bit machine, so I have this code:
${If} ${RunningX64}
WriteRegStr HKLM "Software\Wow6432Node\blahblah" "Path" $INSTDIR
${Else}
WriteRegStr HKLM "Software\blahblah" "Path" $INSTDIR
${EndIf}
This works **most of the time** but not always. Sometimes, when I run it on a 64-bit machine, it creates an additional level:
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Wow6432Node\blahblah.
Can someone shed some light on this?
Thanks.
-- DC Dweller
Afrow UK
25th May 2011 19:34 UTC
You don't need to specify both registry keys. This is enough for both 32-bit and 64-bit:
WriteRegStr HKLM "Software\blahblah" "Path" $INSTDIR
Windows handles the redirection for you (try it). If you don't want to write to Wow6432Node then you use SetRegView 64, but otherwise it will always write to Wow6432Node on Windows 64 (because NSIS installers are 32-bit).
Stu
dc_dweller
25th May 2011 21:08 UTC
Thanks for replying. You are right, and I ended up doing just that.
I did notice one thing which implies a bug in NSIS:
If the registry key HKEY_LOCAL_MACHINE\Software\Wow6432Node\BlahBlah already exists, then the command
WriteRegStr HKLM "Software\Wow6432Node\blahblah" "Path" $INSTDIR
works properly, but if it does not exist, then this command writes to
HKEY_LOCAL_MACHINE\Software\Wow6432Node\Wow6432Node\blahblah
Anders
25th May 2011 21:17 UTC
NSIS just passes the string to the registry API, this redirection is probably by design, you are not really supposed to hardcode the Wow6432 key anywhere. If you are only doing 32bit stuff, don't think about x64 redirection at all and everything should be fine...