Windows – NSIS installer – define installer and system x32/x64

64-bitinstallationnsispathwindows

I am trying to set proper installation folder for my application.
Can I detect if installer is for 32 or 64 bit system? Because now when I install x32 application on x64 system, the InstallDir is incorrect.

I have one build script for x32 and x64 installer and I use x64.nsh to define program files path. But here is problem: Even if installer detects x64 system, if current build is x32, it will be still installed in "C:\Program Files" instead of "C:\Program Files (x86)".

On worst case scenario I will have to create two build scripts for two installers (x32, x64), but I want to avoid it.

So, is there any way to define if installer is for 32 or 64 bit systems?

Best Answer

I had the same issue. Ended up using a wrapper script that passed the arch of the application to the nsi script (makensis.exe /DARCH=x86/x64) and something like this in the nsi script itself:

${If} ${RunningX64}
  ${If} ${ARCH} == "x64"
    StrCpy $InstDir "$PROGRAMFILES64\${PROGNAME}"
  ${Else}
    StrCpy $InstDir "$PROGRAMFILES32\${PROGNAME}"
  ${Endif}
${Else}
  ${If} ${ARCH} == "x64"
    Quit
  ${Else}
    StrCpy $InstDir "$PROGRAMFILES\${PROGNAME}"
  ${Endif}
${EndIf}
Related Topic