Situation
I am trying to run a command line tool tool, DISM.exe, programmatically. When I run it manually, it works, but when I try to create it with the following:
var systemPath = Environment.GetFolderPath(Environment.SpecialFolder.System); var dism = new Process(); dism.StartInfo.FileName = Path.Combine(systemPath, "Dism.exe"); dism.StartInfo.Arguments = "/Online /Get-Features /Format:Table"; dism.StartInfo.Verb = "runas"; dism.StartInfo.UseShellExecute = false; dism.StartInfo.RedirectStandardOutput = true; dism.Start(); var result = dism.StandardOutput.ReadToEnd(); dism.WaitForExit();
Then my result appears as:
Error: 11
You cannot service a 64-bit operating system with a 32-bit version of DISM. Please use the version of DISM that matches your computer architecture.
Problem
I really already know what causes this: my project is configured to compile for the x86 platform. (See this question , although none of the answers mention this.) However, unfortunately, at the moment we insist that we continue to aim at this platform, I can not fix it by switching to any CPU.
So my question is how to programmatically start a process in a way that does not depend on the platform of its parent, i.e. save my project with x86 targeting, but run a process that will target the correct platform for the machine it is running on.
source share