1.实例1
public static void TestOne() { Process p = new Process(); p.StartInfo.FileName = "cmd.exe"; p.StartInfo.UseShellExecute = false; p.StartInfo.RedirectStandardInput = true; p.StartInfo.RedirectStandardOutput = true; p.StartInfo.RedirectStandardError = true; p.StartInfo.CreateNoWindow = true; p.Start(); p.StandardInput.WriteLine("systeminfo" + "&exit"); p.StandardInput.AutoFlush = true; string result = p.StandardOutput.ReadToEnd(); p.WaitForExit(); p.Close(); Console.WriteLine(result); }
显示结果:
时间: 2024-10-03 23:25:19