helloyesyes 发表于 2013-2-1 09:51:08

C# 调用cmd.exe的方法

网上有很多用C#调用cmd的方法,大致如下:

<span style="color: #000000;">private void ExecuteCmd(string command)      {            Process p = new Process();            p.StartInfo.FileName = "cmd.exe";            p.StartInfo.UseShellExecute = false;            p.StartInfo.RedirectStandardInput = true;            p.StartInfo.RedirectStandardOutput = true;            p.StartInfo.CreateNoWindow = true;            p.Start();            p.StandardInput.WriteLine(command);            p.StandardInput.WriteLine("exit");            p.WaitForExit();            this.textBox1.Text=textBox1.Text+ p.StandardOutput.ReadToEnd();            p.Close();      }
页: [1]
查看完整版本: C# 调用cmd.exe的方法