c# - 从 System.Diagnostics.Process 调用 dism.exe 失败

标签 c# visual-studio windows-server-2008-r2 system.diagnostics

为了在 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/

相关文章:

c - 错误 C2011 : 'timezone' :'struct' type redefinition (postgres)

visual-studio - Visual Studio 中特定解决方案的默认浏览器

c# - 批处理脚本在调用 exe 后错误退出

c# - 有没有办法表示很长的数字?

c# - 使用WPF中的MVVM从UserControl冒泡事件。

c# - 将 RGB 转换为 HSB 颜色

c# - WPF DataGridTemplateColumn 组合框更新所有行

css - MVC3 Web 应用程序 - IIS7 Windows Server 2008 R2 - CSS 问题

playframework - 如何将Play Framework 2.0应用程序作为Windows服务运行?