By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,583 Members | 617 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,583 IT Pros & Developers. It's quick & easy.

How to Call dos command like "ping 10.0.0.1" and trace the respond?

P: n/a


--
Tech Servant James Pang.
Nov 17 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Hey,

Use System.Diagnostics.Process class that will run a process.

Than redirect its output by setting the process
StartInfo.RedirectStandardOutput = true.

this Will redirect the output to the process instance and then you can use
basic streaming mechanism to trace the respond.

-Moty-

"James Pang" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...


--
Tech Servant James Pang.

Nov 17 '05 #2

P: n/a
thank you

--
Tech Servant James Pang.
"Moty Michaely" <mo**@speedocs.co.il> 写入消息新闻:ex**************@TK2MSFTNGP09.phx.gbl ...
Hey,

Use System.Diagnostics.Process class that will run a process.

Than redirect its output by setting the process
StartInfo.RedirectStandardOutput = true.

this Will redirect the output to the process instance and then you can use
basic streaming mechanism to trace the respond.

-Moty-

"James Pang" <news.microsoft.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...


--
Tech Servant James Pang.


Nov 17 '05 #3

P: n/a
Hey thank you very much but

myProcess.StartInfo.FileName==@"C:\WINDOWS\system3 2\ping.exe 10.0.0.1";
//this will not work cant find file name...

myProcess.StartInfo.FileName==@"C:\WINDOWS\system3 2\ping.exe"; //this works
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.Verb="10.0.0.1";

// myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.UseShellExecute=false;
myProcess.Start();

string output =myProcess.StandardOutput.ReadToEnd();
System.Console.WriteLine(output);

Nov 17 '05 #4

P: n/a
Right..

You must use Arguments property for your purpose.

myProcess.FileName = @"C:\Windows\System32\Ping.exe"
myProcess.Arguments = "10.0.0.1"

using Verb property is not so good option I think.

If it works for you, great.

- Moty -

"James Pang" <news.microsoft.com> wrote in message
news:uc**************@TK2MSFTNGP14.phx.gbl...
Hey thank you very much but

myProcess.StartInfo.FileName==@"C:\WINDOWS\system3 2\ping.exe 10.0.0.1";
//this will not work cant find file name...

myProcess.StartInfo.FileName==@"C:\WINDOWS\system3 2\ping.exe"; //this
works
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess.StartInfo.Verb="10.0.0.1";

// myProcess.StartInfo.Verb = "Print";
myProcess.StartInfo.CreateNoWindow = true;
myProcess.StartInfo.UseShellExecute=false;
myProcess.Start();

string output =myProcess.StandardOutput.ReadToEnd();
System.Console.WriteLine(output);

Nov 17 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.