c# - Programatically start a process independent of platform -


situation

i trying run command-line tool, dism.exe, programmatically. when run manually works, when try spawn 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 result comes out as:

error: 11

you cannot service running 64-bit operating system 32-bit version of dism. please use version of dism corresponds computer's architecture.

problem

i'm aware of causes this: project set compile x86 platform. (see this question example, although none of answers mention this). however, unfortunately requirement @ moment continue targeting platform, not able fix switching cpu.

so question how programmatically spawn process in way independent of platform of parent- i.e. keep project targeting x86, start process target correct platform machine on.

even though i'm running correct dsim.exe in system32

but you're not. that's point. the file system redirector lies 32-bit processes , when ask system32 x86 process, file syswow64. if want access 64-bit exe, need ask via %windir%\sysnative

(%windir% being specialfolder.windows)


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -