Syntax for the "Start" method

  • Thread starter Thread starter Greg Smith
  • Start date Start date
G

Greg Smith

I am trying to use the "Ping" command and capture the
output. I can run it with the following:

System.Diagnostics.Process.Start("ping.exe","-a
123.123.123.123");

This works fine. However, when I attempt to redirect the
output to a file using:

System.Diagnostics.Process.Start("ping.exe", " -a
123.123.123.123 > c:\\temp\\ping.txt");

This does not work. What would the correct syntax be for
this?

Any help is greatly appreciated.

P.S. Is there any other way to capture this output into
my program?
 
System.Diagnostics.Process p = new System.Diagnostics.Process();

p.StartInfo.FileName = "ping";

p.StartInfo.RedirectStandardOutput = true;

p.StartInfo.Arguments = " -a 123.123.123.123";

p.Start();

p.WaitForExit();

string output = p.StandardOutput.ReadToEnd();



Chris
 
try

Process.Start("cmd.exe", "/c ping.exe -a 123.123.123.123 >
c:\\temp\\ping.txt");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top