// #you will need the other usual using statements besides this one. using System.Diagnostics; // #start a new process Process p = new Process(); // #tells operating system not to use a shell; p.StartInfo.UseShellExecute = false; //#need this false to capture results in stdout //#allow me to capture stdout, i.e. results p.StartInfo.RedirectStandardOutput = true; //#my command arguments, i.e. what site to ping p.StartInfo.Arguments="www.yahoo.com"; //#the command to invoke under MSDOS p.StartInfo.FileName=@"c:\ping"; //#do not show MSDOS window p.StartInfo.CreateNoWindow=true; //#do it! p.Start(); //#capture results string output = p.StandardOutput.ReadToEnd(); //#wait for all results. p.WaitForExit(); //#show results. MessageBox.Show(output.ToString(),"result");
Build Your Own ASP.NET Website Using C# & VB.NET