- NSIS Discussion
- Update 32 bit installer with 64 bit
Archive: Update 32 bit installer with 64 bit
Maxim30
31st January 2010 21:15 UTC
Update 32 bit installer with 64 bit
Hello,
I would change the default $PROGRAMFILES constant, in InstallDir attribute for a 32 bit system, into another one that shift to $PROGRAMFILES64 for a 64 bit system but remaining $PROGRAMFILES for 32 bit systems.
I have tried to use the constant ${RunningX64} from "x64.nsh" script with LogicLib and StrCmp functions but this do not work.
Do you know a script that make this ?
Greetings
MSG
1st February 2010 07:24 UTC
If the macros in x64.nsh did not work, you're using them wrong. Can you show us how you use them?
Maxim30
1st February 2010 09:42 UTC
Hello,
here there the code:
!include "LogicLib.nsh"
!include "WinVer.nsh"
!include "x64.nsh"
...
InstallDir "$R0\${Nome}"
...
Function .onInit
${If} ${RunningX64}
StrCpy $R0 "$PROGRAMFILES64"
${Else}
StrCpy $R0 "$PROGRAMFILES32"
${EndIf}
FunctionEnd
Only the variable ${Nome} is recognized by the installer in the path box.
What's wrong ?
MSG
1st February 2010 12:30 UTC
InstallDir is a compile-time command. The onInit function is executed at runtime. Obviously, when you're compiling the installer, $R0 does not yet contain any value.
What you want to do is this:
Function .onInit
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${Nome}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES32\${Nome}"
${EndIf}
FunctionEnd
Maxim30
1st February 2010 13:54 UTC
Originally posted by MSG
InstallDir is a compile-time command. The onInit function is executed at runtime. Obviously, when you're compiling the installer, $R0 does not yet contain any value.
What you want to do is this:
Function .onInit
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${Nome}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES32\${Nome}"
${EndIf}
FunctionEnd
Now it works, BUT what's about the InstallDir attribute ? If I omit now it or if I set it to $INSTDIR argument, then the setup, at the next running, does not recognixe the previous installation folder when using also the attribute InstallDirRegKey.
Can it be fixed ?
MSG
1st February 2010 14:38 UTC
InstallDirRegkey is an ancient NSIS command and shouldn't be used anymore if you ask me. Just do:
ReadRegStr $0 (your registry path here)
${If} $0 == ""
${If} ${RunningX64}
etc...
${EndIf}
Maxim30
1st February 2010 16:44 UTC
Originally posted by MSG
InstallDirRegkey is an ancient NSIS command and shouldn't be used anymore if you ask me. Just do:
ReadRegStr $0 (your registry path here)
${If} $0 == ""
${If} ${RunningX64}
etc...
${EndIf}
My attribute is:
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Nome}" "NSIS:InstallDir".
How it should be placed into your code above ? And what should I fill into the etc... section of your code above ?
Joel
1st February 2010 19:16 UTC
Originally posted by MSG
InstallDirRegkey is an ancient NSIS command and shouldn't be used anymore if you ask me. Just do:
ReadRegStr $0 (your registry path here)
${If} $0 == ""
${If} ${RunningX64}
etc...
${EndIf}
Agree, but helps getting a prev installed path :)
Maxim30
1st February 2010 19:23 UTC
Originally posted by Maxim30
My attribute is:
InstallDirRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Nome}" "NSIS:InstallDir".
How it should be placed into your code above ? And what should I fill into the etc... section of your code above ?
I found this code and it seems to work:
ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\${Nome}" "NSIS:InstallDir"
${If} $0 != ""
StrCpy $INSTDIR $0
${ElseIf} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${Nome}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES32\${Nome}"
${EndIf}
MSG
2nd February 2010 06:38 UTC
Maxim30, for information on how to use ReadRegStr, please see the manual:
http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.2.12