如何从32位进程启动一个64位进程进程

2023-09-02 01:40:15 作者:北溟有鱼

我试图运行从我们的32位.NET应用程序在64位可执行文件(java.exe的)。我使用进程类,并调用 CMD /℃下命令名称> ,以支持所有可能的命​​令(如 DIR 光盘等)。

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: Windows System32下文件夹中(64位)。我曾尝试explicily启动64位版本的 CMD.EXE 致电 C: WINDOWS SYSTEM32 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?

修改整 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文件系统重定向,相应的API为P / Invoke的是Wow64DisableWow64FsRedirection和Wow64RevertWow64FsRedirection.

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.