How to ping another computer in Vb.net 2003

  • Thread starter Thread starter Robert Dufour
  • Start date Start date
R

Robert Dufour

Its easy in 2005 but I'm stuck with 2003 for now

Can anyone provide a snippet of code?
Thanks for any help.
Bob
 
Robert.

if it's not built in then you probably need to use API check out the
IPHLPAPI.DLL (IP helper API)

it has alot of the IGMP protocol stuff in it.

Michael.
 
When I had to do it in 2003, I just used an external program called
fping.exe and read back it's output.
 
You can use WMI (add referrence/import to system.management)

Dim objPing As New SelectQuery("SELECT StatusCode FROM Win32_PingStatus
where address='" & machinename_or_ipaddress & "'")
Dim objSearch as New ManagementObjectSearcher(objPing)
Dim PingStatus As String = ""
For Each objItem as In objSearch.Get()
PingStatus = objItem("StatusCode").ToString
Next
if PingStatus <> "0" Then
' failed
else
'success
end if

HTH,

Phil
 
You can forever use the application start.

\\\
Dim p As New Process
Dim pi As New ProcessStartInfo
pi.UseShellExecute = False
pi.RedirectStandardOutput = True
pi.Arguments = "www.google.com"
pi.WorkingDirectory = "C:\windows\system32"
'this for nt* computers
pi.FileName = "ping"
p.StartInfo = pi
p.StartInfo = pi
p.Start()
Dim sr As IO.StreamReader = p.StandardOutput
Dim sb As New System.Text.StringBuilder("")
Dim input As Integer = sr.Read
Do Until input = -1
sb.Append(ChrW(input))
input = sr.Read
Loop
MessageBox.Show(sb.ToString)
///

Cor
 
Back
Top