21 lines
792 B
C#
21 lines
792 B
C#
using System;
|
|
|
|
namespace GetSystemCommandOutput {
|
|
class Program {
|
|
static void Main(string[] args) {
|
|
System.Diagnostics.Process process = new System.Diagnostics.Process();
|
|
System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
|
|
startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
|
startInfo.FileName = "cmd.exe";
|
|
startInfo.Arguments = "/c echo Hello World";
|
|
startInfo.RedirectStandardOutput = true;
|
|
startInfo.UseShellExecute = false;
|
|
process.StartInfo = startInfo;
|
|
process.Start();
|
|
|
|
string output = process.StandardOutput.ReadToEnd();
|
|
Console.WriteLine("Output is {0}", output);
|
|
}
|
|
}
|
|
}
|