'Is it possible for 32 bit NSIS to launch a 64 bit program?

I'm porting a windows program from 32 -> 64 bit. It has a 32 bit installer which is written using NSIS. Can I launch one of my new 64 bit exes using the 32 bit NSIS installer? I don't think there is a 64 bit version of NSIS...



Solution 1:[1]

Sure you can, NSIS doesn't impose any restrictions and what's really nifty about NSIS is if you have both 32 and 64 bit versions of your app, you can do a combined installer, and install the required files on a per-architecture basis. e.g.

!include "x64.nsh"

${If} ${RunningX64}
    File ..\x64\blah.exe
${Else}
    File ..\x86\blah.exe
${EndIf}

Solution 2:[2]

For executing processes needing 64-bit operation I found the default NSIS execution would not automatically run in 64-bit mode. I encountered this when trying to run DISM to install .NET Framework 3.5. DISM would error out stating:

"You cannot service a running 64-bit operating system with a 32-bit version of DISM."

To resolve I added needed to add DisableX64FSRedirection before the call that needs 64-bit operation. See below for example:

${If} ${RunningX64}
   ${DisableX64FSRedirection}
   DetailPrint "Disabling Windows 64-bit file system redirection"
${EndIf}

nsExec::ExecToStack 'Dism.exe /Online /Enable-Feature /FeatureName:NetFx3'

${If} ${RunningX64}
   ${EnableX64FSRedirection}
   DetailPrint "Re-enabling Windows 64-bit file system redirection"
${EndIf}

Solution 3:[3]

just to add more descriptive

have a look, http://www.autoitscript.com/forum/index.php?showtopic=44048

Solution 4:[4]

Well.. there are some restrictions here.. for instance, try run odbcconf.exe to install a driver. I have not been able to figure out a way to make that come in as a 64bit entry. Same way I think as if you (in a 64bit system) start "powershell x86" as admin, then run cmd and odbcconf from there - no easy way to get around it that I can find, making odbcconf do x64

Solution 5:[5]

To launch a 64-bit PowerShell window and run a script from 32-bit setup

!include "x64.nsh"

SetOutPath "$INSTDIR"
${If} ${RunningX64}
    NsExec::ExecToStack "$WINDIR\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File .\example.ps1"
${Else}
    NsExec::ExecToStack "powershell.exe -ExecutionPolicy Bypass -NoProfile -NonInteractive -File .\example.ps1"
${EndIf}
Pop $0
DetailPrint "Program returned $0"

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 saschabeaumont
Solution 2 sonyisda1
Solution 3 K. Santosh
Solution 4 Stoker
Solution 5 Andrei Krasutski