Process p = new Process();
p.StartInfo.FileName = "cmd.exe"; //设定程序名
p.StartInfo.UseShellExecute = false; //关闭Shell的使用
p.StartInfo.RedirectStandardInput = true; //重定向标准输入
p.StartInfo.RedirectStandardOutput = true; //重定向标准输出
p.StartInfo.RedirectStandardError = true; //重定向错误输出
p.StartInfo.CreateNoWindow = true; //设置不显示窗口
p.Start(); //启动进程
p.StandardInput.WriteLine("ping www.baidu.com ");//输入要执行的命令
p.StandardInput.WriteLine("exit");
//按钮控件的单击事件代码如下:
private void button1_Click(object sender, EventArgs e)
{
System.Diagnostics.Process.Start("cmd.exe", "ping www.baidu.com ");
}
winform调用dos命令
最新推荐文章于 2017-01-19 10:07:19 发布