【发布时间】:2017-12-13 10:22:18
【问题描述】:
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();
我得到输出:
您无法使用 32 位版本的 DISM 为正在运行的 64 位操作系统提供服务。 请使用与您的计算机体系结构相对应的 DISM 版本。
已尝试文件名: "C:\WINDOWS\SYSTEM32\dism.exe" 和 "C:\WINDOWS\SYSWOW64\dism.exe"
仍然得到相同的结果。
机器在 Windows 7 Embedded 上运行。
编辑: 试过了:
但还是不行..
【问题讨论】:
-
可以从命令行执行命令吗?另外,您说您在不同的文件夹中尝试了两种不同版本的
dism.exe。但是,您提供的代码未指定文件夹。您的问题似乎与编程无关,而是执行与您的操作系统匹配的正确命令的问题。 -
当我从命令行执行时它运行良好。找到了可以试一试的东西。如果效果不好,贴出来:)
-
@Nenad,也许您的 Wpf 应用程序是 64 位编译的,并且无法调用 32 位版本的 dism.exe,但我不知道。
-
File System Redirection 可以在这里应用。