Is it possible for 32 bit NSIS to launch a 64 bit program?
Asked Answered
P

6

7

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...

Prentiss answered 9/11, 2009 at 11:47 Comment(0)
G
11

NSIS uses two Win32 APIs to execute processes ShellExecute (thru ExecShell) and CreateProcess (thru Exec and ExecWait), both of them can run 64 bit process (x64) from NSIS 32 bit process (as long as you're running on 64 bit OS).

Gynaeceum answered 9/11, 2009 at 11:50 Comment(3)
Oh ok, I didn't think it was possible to create a 64 bit process from a 32 bit one. Is there anything special I have to do?Prentiss
I consistently find that when I launch things like cmd they are stuck in 32-bit mode and cannot run any 64-bit utilities (windows 10 64-bit). @sonyisda1's answer is betterBenia
@Benia I know how to solve this problem, see my answer here.Roxanaroxane
E
15

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}
Evertor answered 10/11, 2009 at 0:39 Comment(2)
Hi i know this is old but i have tried this and it still seems to install the 32bit.exe if i try this method. Why oh why?Lahr
@DanielCasserly there shouldn't be anything magical - that's the code I'm still using. It was grabbed from an example on the NSIS site when I was first building my installerEvertor
G
11

NSIS uses two Win32 APIs to execute processes ShellExecute (thru ExecShell) and CreateProcess (thru Exec and ExecWait), both of them can run 64 bit process (x64) from NSIS 32 bit process (as long as you're running on 64 bit OS).

Gynaeceum answered 9/11, 2009 at 11:50 Comment(3)
Oh ok, I didn't think it was possible to create a 64 bit process from a 32 bit one. Is there anything special I have to do?Prentiss
I consistently find that when I launch things like cmd they are stuck in 32-bit mode and cannot run any 64-bit utilities (windows 10 64-bit). @sonyisda1's answer is betterBenia
@Benia I know how to solve this problem, see my answer here.Roxanaroxane
A
5

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}
Adder answered 17/1, 2017 at 19:31 Comment(2)
Doesn't work for powershell.exe launches a 32-bit PowerShell windowRoxanaroxane
@AndreiKrasutski this is a known issue as noted in the pitfall section hereAdder
R
2

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"
Roxanaroxane answered 28/4, 2022 at 20:52 Comment(0)
T
1

just to add more descriptive

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

Turnbull answered 8/2, 2010 at 2:49 Comment(0)
U
0

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

Unvarnished answered 25/2, 2015 at 16:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.