private   void   button1_Click(object   sender,   EventArgs   e) 
{ 
      try 
      { 
              Process   p   =   new   Process(); 
              p.StartInfo.FileName   =   "cmd.exe "; 
              p.StartInfo.UseShellExecute   =   false; 
              p.StartInfo.RedirectStandardInput   =   true; 
              p.StartInfo.RedirectStandardOutput   =   true; 
              p.StartInfo.RedirectStandardError   =   true; 
              p.StartInfo.CreateNoWindow   =   true; 
              p.Start(); 
              p.StandardInput.WriteLine( "ping   172.16.1.1 "); 
              p.StandardInput.WriteLine( "exit "); 
              string   strRst   =   p.StandardOutput.ReadToEnd(); 
              p.WaitForExit(); 
              this.label1.Text   =   strRst; 
        } 
          catch   (Exception   err) 
          { 
                MessageBox.Show(err.Message);   //显示错误信息。 
        } 
} 

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2021-12-06
  • 2021-12-06
  • 2021-11-27
  • 2021-07-14
  • 2022-12-23
猜你喜欢
  • 2021-08-09
  • 2021-11-25
  • 2021-12-06
  • 2021-11-15
  • 2021-07-01
  • 2022-12-23
相关资源
相似解决方案