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
Update 32 bit installer with 64 bit
10 posts
If the macros in x64.nsh did not work, you're using them wrong. Can you show us how you use them?
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 ?
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 ?
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
What you want to do is this:
Function .onInit
${If} ${RunningX64}
StrCpy $INSTDIR "$PROGRAMFILES64\${Nome}"
${Else}
StrCpy $INSTDIR "$PROGRAMFILES32\${Nome}"
${EndIf}
FunctionEnd
Originally posted by MSGNow 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.
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
Can it be fixed ?
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}
Originally posted by MSGMy attribute is:
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}
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 ?
Originally posted by MSGAgree, but helps getting a prev installed path 🙂
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}
Originally posted by Maxim30I found this code and it seems to work:
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 ?
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}
Maxim30, for information on how to use ReadRegStr, please see the manual: