32位NSIS可以启动64位程序吗?

发布于 2024-08-10 18:22:32 字数 124 浏览 8 评论 0原文

我正在从 32 -> 移植 Windows 程序64 位。它有一个使用 NSIS 编写的 32 位安装程序。我可以使用 32 位 NSIS 安装程序启动我的新 64 位 exe 之一吗?我认为 NSIS 没有 64 位版本...

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

执妄 2024-08-17 18:22:32

当然可以,NSIS 不会施加任何限制,NSIS 的真正妙处在于,如果您同时拥有 32 位和 64 位版本的应用程序,您可以执行组合安装程序,并在每个体系结构的基础上安装所需的文件。例如

!include "x64.nsh"

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

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}
我纯我任性 2024-08-17 18:22:32

NSIS 使用两个 Win32 API 来执行进程 ShellExecute(通过ExecShell) 和 CreateProcess (通过 ExecExecWait),两者都可以运行64位进程(x64) 来自 NSIS 32 位进程(只要您在 64 位操作系统上运行)。

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

隔岸观火 2024-08-17 18:22:32

对于需要 64 位操作的执行进程,我发现默认的 NSIS 执行不会自动在 64 位模式下运行。我在尝试运行 DISM 来安装 .NET Framework 3.5 时遇到了此问题。 DISM 会出错并指出:

“您无法使用 32 位操作系统为正在运行的 64 位操作系统提供服务
DISM 版本。”

我添加了需要在需要 64 位操作的调用之前添加 DisableX64FSRedirection。请参阅下面的示例:

${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}

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}
各自安好 2024-08-17 18:22:32

启动 64 位 PowerShell 窗口并从 32 位安装程序运行脚本

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

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"
国际总奸 2024-08-17 18:22:32

嗯..这里有一些限制..例如,尝试运行
odbcconf.exe 安装驱动程序。我一直没能找到一种方法让它以 64 位条目的形式出现。
我认为就像你(在 64 位系统中)以管理员身份启动“powershell x86”,然后从那里运行 cmd 和 odbcconf - 我找不到简单的方法来绕过它,让 odbcconf 执行 x64

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文