为了在 Windows 2008 R2 Server(64 位)中启用 Microsoft-Hyper-V 和 Microsoft-Hyper-V-Management,我将 dism.exe 作为进程调用。我使用的命令是
Dism.exe /online /Get-FeatureInfo /FeatureName:Microsoft-Hyper-V
Dism.exe /online /Get-FeatureInfo /FeatureName:Microsoft-Hyper-V-Management-Clients
当我从命令行执行它时它工作正常但当我尝试通过我的代码执行它时它失败了。我已经在 C:\Windows\SysWoW64 文件夹下尝试了 64 位版本的 Dism.exe,但它也失败了。这是我收到的错误消息,
You cannot service a running 64-bit operating system with a 32-bit version of DISM. Please use the version of DISM that corresponds to your computer's architecture.
我在这里错过了什么?
更新:SLaks 是对的,但问题出在默认情况下 MS Visual Studio Express 版本以 x86 为目标,我必须在 .csproj 文件中手动将其编辑到 AnyCPU 以使其工作。
最佳答案
因为您在 32 位进程中运行,所以您是 getting redirected to the 32-bit version in SysWoW64
运行 %WINDIR%\SysNative\dism.exe
以防止重定向。
关于c# - 从 System.Diagnostics.Process 调用 dism.exe 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5936719/