如何从32位进程启动64位进程
收藏

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

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

为了使它正常工作,我还能做些什么?

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是Wow64DisableWow64FsRedirection和Wow64RevertWow64FsRedirection。

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

    公众号
    关注公众号订阅更多技术干货!