Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling dism.exe from System.Diagnostics.Process Fails

For enabling Microsoft-Hyper-V and Microsoft-Hyper-V-Management in Windows 2008 R2 Server(64bit), I'm calling dism.exe as a process. The command I've used is

Dism.exe /online /Get-FeatureInfo /FeatureName:Microsoft-Hyper-V

Dism.exe /online /Get-FeatureInfo /FeatureName:Microsoft-Hyper-V-Management-Clients

This works fine when I execute this from the command line but it fails when I try to execute it through my code. I've tried the 64bit version of Dism.exe under the C:\Windows\SysWoW64 folder but it fails too. Here is the error message I get,

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.

What am I missing here?

UPDATE: SLaks was right, but the issue turned out to be that MS Visual studio express edition by default targets x86 which I had to manually edit in the .csproj file to AnyCPU to make it work.

like image 483
Sivakumar Kailasam Avatar asked May 09 '11 12:05

Sivakumar Kailasam


People also ask

Can DISM fix Windows Update?

Windows updates and service packs may fail to install if there are corruption errors. For example, an update might not install if a system file is damaged. The DISM or System Update Readiness tool may help you to fix some Windows corruption errors.

What is a DISM?

Deployment Image Servicing and Management (DISM) is a command-line tool that is used to service Windows images. You can use DISM image management commands to mount and get information about Windows image (. wim) files, Full-flash utility (FFU) files, or virtual hard disks (VHD).


1 Answers

Because you're running in a 32-bit process, you're getting redirected to the 32-bit version in SysWoW64

Run %WINDIR%\SysNative\dism.exe to prevent redirection.

like image 186
SLaks Avatar answered Sep 24 '22 18:09

SLaks