3
Process p = new Process();
p.StartInfo.FileName = "dism";
p.StartInfo.Arguments = "/online /get-packageinfo /packagename:WinEmb-File-Based-Write-Filter~31bf3856ad364e35~amd64~~6.1.7601.17514";
p.StartInfo.UseShellExecute = false;
p.StartInfo.RedirectStandardError = true;
p.StartInfo.CreateNoWindow = true;
p.StartInfo.RedirectStandardOutput = true;
p.StartInfo.RedirectStandardInput = true;
p.Start();

string output = p.StandardOutput.ReadToEnd();

p.WaitForExit();
p.Close();

I get output:

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.

Tried for FileName: "C:\WINDOWS\SYSTEM32\dism.exe" and "C:\WINDOWS\SYSWOW64\dism.exe"

and still getting same result.

Machine is running on Windows 7 Embedded.

EDIT: Have tried:

Calling dism.exe from System.Diagnostics.Process Fails

But still not working..

Nenad
  • 316
  • 2
  • 14
  • Can you execute the command from the command line? Also, you say that you tried two different versions of `dism.exe` in different folders. However, the code that you have provided does not specify a folder. Your problem does not seem to be related to programming and is rather a problem of executing the correct command that matches your operating system. – Martin Liversage Dec 13 '17 at 10:28
  • When i execute from command line it goes well. Found something gonna try it.. If it works ill post it :) – Nenad Dec 13 '17 at 10:34
  • 1
    @Nenad, perhaps your Wpf app is compiled in 64-bit and have trouble calling 32-bit version of dism.exe but I don't know. – derloopkat Dec 13 '17 at 10:56
  • [File System Redirection](https://msdn.microsoft.com/en-us/library/windows/desktop/aa384187(v=vs.85).aspx) could be applied here. – Caramiriel Dec 13 '17 at 11:23
  • Also, possible duplicate of [Calling dism.exe from System.Diagnostics.Process Fails](https://stackoverflow.com/questions/5936719/calling-dism-exe-from-system-diagnostics-process-fails) ? – Caramiriel Dec 13 '17 at 11:27
  • @derloopkat You were right! Thanks all for help! Posted my code thats currently working :) – Nenad Dec 13 '17 at 12:16

2 Answers2

2

Found solution! Make all projects/setups 64bit build.

And by following code its working:

ProcessStartInfo psi = new ProcessStartInfo("cmd");
psi.UseShellExecute = false;
psi.ErrorDialog = false;
psi.RedirectStandardError = true;
psi.RedirectStandardInput = true;
psi.RedirectStandardOutput = true;

Process plinkProcess = new Process();
plinkProcess.StartInfo = psi;
plinkProcess.Start();

StreamWriter inputWriter = plinkProcess.StandardInput;
StreamReader outputReader = plinkProcess.StandardOutput;
inputWriter.WriteLine("dism /online /get-packageinfo /packagename:WinEmb-File-Based-Write-Filter~31bf3856ad364e35~amd64~~6.1.7601.17514");
inputWriter.WriteLine("exit");
inputWriter.Flush();

plinkProcess.WaitForExit();

string strOutput = outputReader.ReadToEnd();

plinkProcess.Close();
Nenad
  • 316
  • 2
  • 14
0

Although already answered I've run into this issue multiple times. WinPE does not have compatibility with different architectures. So 64-bit WinPE has to run programs compiled for its architecture. As for dism there is a 64-bit and 32-bit versions when you install the WAIK or Windows Kits. 64-bit dism C:\Program Files\Windows AIK\Tools\amd64\Servicing\dism.exe 32-bit dism C:\Program Files\Windows AIK\Tools\x86\Servicing\dism.exe

John112358
  • 98
  • 10