473,386 Members | 1,790 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Syntax for the "Start" method

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?
Nov 15 '05 #1
2 12827
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

"Greg Smith" <gj*@umn.edu> wrote in message
news:0d****************************@phx.gbl...
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?

Nov 15 '05 #2
try

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

"Greg Smith" <gj*@umn.edu> wrote in message
news:0d****************************@phx.gbl...
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?

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: madmanpierre | last post by:
I have a Mobile Pocket PC app written in .NET, I notice that Explorer and other programs, when running, show up on the Start menu right below Start and right above Today in a list of icons on that...
0
by: The Last Danish Pastry | last post by:
A couple of days ago there was a thread "Returning the machine epsilon". The responses in that thread suggested using Double.Epsilon or Single.Epsilon. Since both these seem to return zero I...
4
by: choihead | last post by:
Hi All, How can i excuete a bat file by c#? I used System.Diagnostics.Process.Start("../stage.bat"); but it cannot find the file, is this the correct method to call the bat file? thx...
3
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
2
by: Dean Slindee | last post by:
The code below is being used to launch WinWord.exe from a VB.NET program. Word launches, but displays this error message: "Word has experienced an error trying to open the file. Try these...
2
by: Brian | last post by:
Is there a way to set the "start in" folder for a windows service? I am running under the Local System account, and the start in folder seems to be "c:\windows\system32". I use some relative...
2
by: holysmokes99 | last post by:
I am developing a component in .Net 1.1, and want to debug it using the "start external program" of the debugger in the IDE. The program I want to start references both 1.1 and 2.0 components. The...
0
by: active | last post by:
Sometimes when I After I click "Start Debugging" I get a "File not Found" Exception. Could not load file or assembly 'FormTesting, Version=1.0.2646.36738, Culture=neutral, PublicKeyToken=null'...
4
by: =?utf-8?B?Qm9yaXMgRHXFoWVr?= | last post by:
Hello, what is the use-case of parameter "start" in string's "endswith" method? Consider the following minimal example: a = "testing" suffix="ing" a.endswith(suffix, 2) Significance of...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.