gpt4 book ai didi

c# - 通过 C# 调用 DISM

转载 作者:行者123 更新时间:2023-11-30 17:31:29 29 4
gpt4 key购买 nike

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();

我得到输出:

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.

尝试了文件名:“C:\WINDOWS\SYSTEM32\dism.exe”和"C:\WINDOWS\SYSWOW64\dism.exe"

仍然得到相同的结果。

机器在 Windows 7 Embedded 上运行。

编辑:尝试过:

Calling dism.exe from System.Diagnostics.Process Fails

但还是不行..

最佳答案

已找到解决方案!将所有项目/设置设为 64 位构建。

并通过以下代码运行:

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();

关于c# - 通过 C# 调用 DISM,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47790611/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com