473,395 Members | 1,637 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,395 software developers and data experts.

Performing a ping from within VB.Net

Raf

Hello to the pros,

I have to create an application that performs a "Ping" to an IP-address. The
result (successfull or not successfull)
should be captured by the application and should be shown to the user.

I know that you can perform dos-commands with the SHELL-command.
But is there a possibility to catch the result of this ping-command if I do
it like this.

Does anyone have some suggestions?

Thanks in advance,

Regards,


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.667 / Virus Database: 429 - Release Date: 23-04-04
Nov 22 '05 #1
2 5678
Hi, Raf

you can do this. Recently people discussed here redirection and capture of
dos commands results - Shell() -? posts.
Thanks to Henry Craven - you can try this sample code - just change called
program and arguments:

Dim ProcID As Integer

Dim sSource As String = "D:\Data\Test"

Dim sDest As String = "D:\VB"

Dim sShell As String = "E:\winnt\System32\xcopy.exe"

Dim s As String = ""

'Try

Dim p As New Process

p.StartInfo.UseShellExecute = False

p.StartInfo.RedirectStandardOutput = True

p.StartInfo.Arguments = "D:\Data\Test D:\VB /e /d /h /o /v"

p.StartInfo.WorkingDirectory = "E:\winnt\system32"

p.StartInfo.FileName = "xcopy"

p.Start()

Dim sr As IO.StreamReader = p.StandardOutput

Dim sb As New System.Text.StringBuilder("")

Dim sinput As String = ""

Do Until sinput = "-1"

sb.Append(sr.ReadLine() & ControlChars.CrLf)

sinput = sr.Read

Loop

Dim sw As New IO.StreamWriter("C:\test2.txt")

sw.Write(sb.ToString)

Me.Close()
--
Henry Craven

"Raf" <No****@noserver.no> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...

Hello to the pros,

I have to create an application that performs a "Ping" to an IP-address. The result (successfull or not successfull)
should be captured by the application and should be shown to the user.

I know that you can perform dos-commands with the SHELL-command.
But is there a possibility to catch the result of this ping-command if I do it like this.

Does anyone have some suggestions?

Thanks in advance,

Regards,


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.667 / Virus Database: 429 - Release Date: 23-04-04

Nov 22 '05 #2
On XP and Server 2003 there's a WMI class, look at Win32_PingStatus. Also:
http://support.microsoft.com/default.aspx?scid=kb;[LN];300197
--
Phil Wilson [MVP Windows Installer]
----
"Raf" <No****@noserver.no> wrote in message
news:Oi**************@TK2MSFTNGP12.phx.gbl...

Hello to the pros,

I have to create an application that performs a "Ping" to an IP-address. The result (successfull or not successfull)
should be captured by the application and should be shown to the user.

I know that you can perform dos-commands with the SHELL-command.
But is there a possibility to catch the result of this ping-command if I do it like this.

Does anyone have some suggestions?

Thanks in advance,

Regards,


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.667 / Virus Database: 429 - Release Date: 23-04-04

Nov 22 '05 #3

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

Similar topics

2
by: Raf | last post by:
Hello to the pros, I have to create an application that performs a "Ping" to an IP-address. The result (successfull or not successfull) should be captured by the application and should be shown...
3
by: Jason Rodman | last post by:
I have downloaded every example on how to create a ping utility in .Net in both VB and C#, but have been disappointed with the results. I have YET to find an example that returns consistent results...
8
by: Jozef | last post by:
Hello, Is there a way to test that an internet connection exists and that you are able to see the webserver before performing any connections? The reason being, when I try to connect to an SQL...
0
by: Ed | last post by:
I've attached some VB.NET code I've hacked together (some taken from MS examples & newsgroup postings) that will perform a ping or IcmpSendEcho using the icmp.dll (see this for more info:...
2
by: Ryan | last post by:
I want to ping every IP on a subnet (255 IP's) and display in a table what IP's are active. I'm currently using a For loop but this takes forever because it pauses to test each Ping. So my guess...
5
by: Deepak | last post by:
I am programing a ping application which pings various centers . I used timer loop and it pings one by one. Now when i finish pinging one center it should wait for the ping_completed function to...
1
by: Krish | last post by:
All, I have an offline application that works online for some data syncronization. For data syncronization I access a webservice. I want to show whether my application is online or not by checking...
5
by: Michael M. | last post by:
I have the following code (listed at bottom of post) that pings a small range of IP address to see which ones are alive. To speed things up a little I am trying to use more than one thread,...
6
by: Dave Marden | last post by:
I currently use this routine in vbscript to ping computers and get the status of ping to determine whether to try to backup a machine, I am trying to change it to work with vb2003.net I am...
2
by: foster99 | last post by:
I am new to VB.NET and I want to implement a timer function into a PING, below is the code which I am using to PING an ip address. I want the PING to be executed something like every 10 seconds, so...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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
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...
0
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
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...

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.