【发布时间】:2017-03-30 10:20:40
【问题描述】:
我正在制作一个必须在 Windows 10 中启用和禁用 UWF 的应用程序。 但是我想截取成功或失败,问题是当我只显示一个字母时。
string output = string.Empty;
string error = string.Empty;
ProcessStartInfo processStartInfo = new ProcessStartInfo("cmd", "/c uwfmgr.exe volume protect c:");
processStartInfo.RedirectStandardOutput = true;
processStartInfo.RedirectStandardError = true;
processStartInfo.UseShellExecute = false;
processStartInfo.Verb = "runas";
Process process = Process.Start(processStartInfo);
using (StreamReader streamReader = process.StandardOutput)
{
output = streamReader.ReadToEnd();
}
using (StreamReader streamReader = process.StandardError)
{
error = streamReader.ReadToEnd();
}
if (!string.IsNullOrEmpty(error))
{
MessageBox.Show("Error: " + error);
return;
}
MessageBox.Show("OK: " + output);
消息框“OK U”来了
谢谢
【问题讨论】:
-
在 cmd.exe 中运行相同的命令会得到什么输出?
标签: c# windows windows-10