C# Process执行cmd指令,实时获取输出并隐藏cmd窗口
如下,执行的时候禁用系统外壳程序即可。////// 获取系统信息//////private string getSystemInfo(){string ret = "系统信息:" + Environment.NewLine;using (Process process = new System.Diagnostics.Process()){pr
·
如下,执行的时候禁用系统外壳程序即可。
/// <summary>
/// 获取系统信息/// </summary>
/// <returns></returns>
private string getSystemInfo()
{
string ret = "系统信息:" + Environment.NewLine;
using (Process process = new System.Diagnostics.Process())
{
process.StartInfo.FileName = "systeminfo";
// 禁用操作系统外壳程序
process.StartInfo.UseShellExecute = false;
process.StartInfo.CreateNoWindow = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();
ret += process.StandardOutput.ReadToEnd() + Environment.NewLine;
}
return ret;
}
更多推荐


所有评论(0)