开发者

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开发者_StackOverflow中文版 64 bit version of NSIS...


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}


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


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}


just to add more descriptive

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


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


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"
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜