static void Main()
{
string back=execCMD("ipconfig");
System.Console.WriteLine(back);
}
public static string execCMD(string command)
{
System.Diagnostics.Process pro = new System.Diagnostics.Process();
pro.StartInfo.FileName = "cmd.exe";
pro.StartInfo.UseShellExecute = false;
pro.StartInfo.RedirectStandardError = true;
pro.StartInfo.RedirectStandardInput = true;
pro.StartInfo.RedirectStandardOutput = true;
pro.StartInfo.CreateNoWindow = true;
//pro.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
pro.Start();
pro.StandardInput.WriteLine(command);
pro.StandardInput.WriteLine("exit");
pro.StandardInput.AutoFlush = true;
//获取cmd窗口的输出信息
string output = pro.StandardOutput.ReadToEnd();
pro.WaitForExit();//等待程序执行完退出进程
pro.Close();
return output;
}