如何从 32 位进程启动 64 位进程 [英] How to start a 64-bit process from a 32-bit process

查看:60
本文介绍了如何从 32 位进程启动 64 位进程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从我们的 32 位 .NET 应用程序运行 64 位可执行文件 (java.exe).我正在使用 Process 类并调用 cmd/c 以支持所有可能的命令(如 dircd 等).

I am trying to run a 64 bit executable (java.exe) from our 32-bit .NET application. I am using Process class and invoking cmd /c <command name> in order to support all possible commands (like dir, cd etc).

问题是我的机器上安装了 64 位版本的 JRE,而 java.exe 只能从 C:WindowsSystem32 文件夹 (x64) 中获得.我已经尝试通过调用 C:WindowsSystem32cmd.exe 显式启动 64 位版本的 cmd.exe 但它被重定向到 SysWOW64> 由于调用进程是 32 位.

The problem is that on my machine I installed 64-bit version of JRE and java.exe is only available from C:WindowsSystem32 folder (x64). I have tried explicily starting 64 bit version of cmd.exe by calling C:WindowsSystem32cmd.exe but it gets redirected to SysWOW64 due to calling process being 32 bit.

我还能做些什么来让它发挥作用?

Is there anything else I can do to get this to work?

EDIT 整个 cmd/c 事情有点牵强附会.这不是问题的一部分,能够运行 64 位可执行文件才是.

EDIT The whole cmd /c thing is a bit of a red herring. It is not part of the problem, being able to run 64 bit executables is.

推荐答案

您可以围绕对 Process.Start 的调用暂时禁用文件系统重定向,P/Invoke 的相应 API 是 Wow64DisableWow64FsRedirectionWow64RevertWow64FsRedirection.

You can temporarily disable filesystem redirection around the call to Process.Start, the appropriate API's to P/Invoke are Wow64DisableWow64FsRedirection and Wow64RevertWow64FsRedirection.

另一种选择是使用 %windir%sysnative,它在 Windows Vista 及更高版本上可用.

Another option is to use %windir%sysnative, which is available on Windows Vista and above.

这篇关于如何从 32 位进程启动 64 位进程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆