mandar ping desde vb

Iniciado por _CrisiS_, 15 Enero 2011, 22:33 PM

0 Miembros y 1 Visitante están viendo este tema.

_CrisiS_

Como podria hacer que al dar clic en un boton se mande un ping  a un IP

si ay conexion se muestre el Messagebox "OK" si no , "FALLO DE CONEXION

raul338

Busca sobre paquetes ICMP

.::IT::.

Pues clases nativas no encontre!!!!!!! pero si te sirve aqui las fuentes del ping pero en C.

http://www.ping127001.com/pingpage/ping.text
Simplemente .::IT::.

WHK

Mira esto, haz un pipe:



Código (vbnet) [Seleccionar]
Public Class Form1

    Private Results As String
    Private Delegate Sub delUpdate()
    Private Finished As New delUpdate(AddressOf UpdateText)
    Dim button_click As Integer = 0
    Dim myprocess As New Process
    Dim StartInfo As New System.Diagnostics.ProcessStartInfo

    Private Sub UpdateText()
        ' txtResults.Text = Results
        txtCommand.Clear()
        txtResults.AppendText(System.Environment.NewLine() & Results)
        txtResults.ScrollToCaret()
    End Sub

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If button_click = 0 Then
            opencmd()
            button_click += 1
        End If
        Dim CMDThread As New Threading.Thread(AddressOf CMDAutomate)
        CMDThread.Start()
    End Sub
   
    Private Sub opencmd()
        StartInfo.FileName = "cmd" 'starts cmd window
        StartInfo.RedirectStandardInput = True
        StartInfo.RedirectStandardOutput = True
        StartInfo.UseShellExecute = False 'required to redirect
        StartInfo.CreateNoWindow = True 'creates no cmd window
        myprocess.StartInfo = StartInfo
        myprocess.Start()
    End Sub

    Private Sub CMDAutomate()
        'Dim SR As System.IO.StreamReader = myprocess.StandardOutput
        'Dim SW As System.IO.StreamWriter = myprocess.StandardInput
        myprocess.StandardInput.WriteLine(txtCommand.Text) 'the command you wish to run.....
        myprocess.StandardInput.WriteLine(System.Environment.NewLine())

        ' SW.WriteLine("exit") 'exits command prompt window
        While myprocess.StandardOutput.EndOfStream = False
            Results = myprocess.StandardOutput.ReadLine()
            Invoke(Finished)
        End While

        'Results = SR.ReadToEnd 'returns results of the command window
        'SW.Close()
        'SR.Close()
        'invokes Finished delegate, which updates textbox with the results text
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
        opencmd()
    End Sub

    Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        Application.ExitThread()
        Application.Exit()
        End
    End Sub
End Class