don't consider the dos promot environment,they belong to different process. you should know about its protocol or using win32 api that may provide help for you.many examples in internet can help you like how to use ping in c#. http://wacle.blogchina.com/359322.html
you should know about its protocol or using win32 api that may provide help for you.many examples in internet can help you like how to use ping in c#.
http://wacle.blogchina.com/359322.html
using System;using System.Diagnostics;namespace ZZ{ class ZZConsole { [STAThread] static void Main(string[] args) { string ip = "127.0.0.1"; string strRst = CmdPing(ip); return;
} private static string CmdPing(string strIp) { 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();
//Console.WriteLine(p.HandleCount.ToString()); p.StandardInput.WriteLine("ping -n 1 "+strIp); p.StandardInput.WriteLine("exit"); string strRst = p.StandardOutput.ReadToEnd(); //Console.WriteLine(strRst);
p.Close(); return strRst; } }}