473,507 Members | 13,917 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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



--
Tech Servant James Pang.
Nov 17 '05 #1
4 6540
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
5143
by: Phil Powell | last post by:
I need to find a PHP equivalent to a very familiar TCL command "subst" (see http://www.hume.com/html84/mann/subst.html ). This command will take a string and evaluate anything TCL inside of it...
7
1643
by: William Morris | last post by:
So, what's the prevailing opinion regarding the use of the "CALL" keyword? I'm working with a third-party ASP application, adapting for our system, and the CALL keyword is used everywhere. I've...
6
6699
by: Clément Collin | last post by:
I working on a GIS project, with Access link which just need a little routine in VBA, but I haven't knowledges in VBA language. It's very simple, and it looks like that in a TPascal way : .......
15
2111
by: Steve Jorgensen | last post by:
I'm looking for coding style opinions. It looks to me like most VB/VBA coders use the command-style syntax for calling subs or functions being treated as subs in a particular context ... Foo...
6
2493
by: Lars-Ove Andersson | last post by:
I have problem with the command "DLookup" in Access 2000. The command takes very long time to run. Have anybody any solution for this. //LOA
5
9995
by: Thom Little | last post by:
Under Visual Studio .NET 2003 I went to View | Other Windows | Command Window and issued csc /t:module StringLib.cs It responded with ... Command "csc" is not valid.
0
1213
by: San Diego Guy | last post by:
Hi all! I have Datagrid. Within that datagrid I have a drop down list that I set up some values in (a "collection") I set up an edit command column on the datagrid and wrote simple code to get...
3
2182
by: Anony Mous | last post by:
Hi, I've run into a problem. I've had postgres V8 beta on my WinXP Pro machine for some time now, and it's been running great. Now, for some reason, I cannot issue any queries to the database...
21
30473
by: Neel | last post by:
I am trying to "ping" a remote host in my C++/Redhat Linux code to check whether that host is connected or not. if (0 == system("ping -w 2 192.168.0.2)) But, in both cases...
0
7109
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7313
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7372
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7029
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7481
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5619
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5039
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
411
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.