【转】C#执行命令行程序/命令并获取输出结果

        //执行命令行命令,获取输出结果
        
//cmd_filename: DOS程序文件名
        
//arguments: 命令行参数
        public static string ExecCMD(string cmd_filename,string arguments)
        {            
            System.Diagnostics.ProcessStartInfo psi 
= new System.Diagnostics.ProcessStartInfo(cmd_filename, arguments);//如:调用ipconfig ,并传入参数: /all 
            psi.CreateNoWindow = true//若为false,则会出现cmd的黑窗体 
            psi.RedirectStandardOutput = true;
            psi.UseShellExecute 
= false;
            System.Diagnostics.Process p 
= System.Diagnostics.Process.Start(psi);
            
return p.StandardOutput.ReadToEnd();
        }
原文地址:https://www.cnblogs.com/SummerRain/p/2080971.html