Results 1 to 5 of 5

Thread: Pinging, Netstating, Tracerting with VB

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    18

    Pinging, Netstating, Tracerting with VB

    I can open cmd and write ping or netstat or tracert or something like that manually. I also know how to
    VB Code:
    1. "shell(""netstat"")"
    But if I do these thing with the shell, I can't see how the respond times were.
    I'd like to create a programm to ping a IP every minute, and solve the ping times in my VB programm, so I can use them for some statistics.
    I also want to do statistics about netstat and so on.

    Can someone help me and tell me how to get these ping times and all the answers to netstat and tracert and all that. I just can't get the answers (outputs) to these commands.

    Thanks a lot
    Last edited by Brainhacker12; Sep 14th, 2005 at 02:12 PM.

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Pinging, Netstating, Tracerting with VB

    You can pipe the results of a command and then open it, either on the screen, or else parse it with your program.
    VB Code:
    1. Option Explicit
    2.  
    3. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, _
    4. ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    5.  
    6. Private Const SW_SHOWNORMAL As Long = 1
    7. Private Const SW_HIDE As Long = 0
    8.  
    9. Private Sub Command1_Click()
    10.     ShellExecute Me.hwnd, "Open", "C:\Windows\System32\CMD.exe", " /c ipconfig >> D:\Myip.txt", "D:\", SW_SHOWNORMAL
    11.     Shell "notepad D:\Myip.txt", SW_SHOWNORMAL
    12. End Sub

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jun 2004
    Posts
    18

    Re: Pinging, Netstating, Tracerting with VB

    really nice idee, thanks
    I haven't thought of the function to transver the results to a file.
    That would be a possibility, but it would be mutch cooler, to read out the infos from the window with a VB programm. Is there a way?

  4. #4
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: Pinging, Netstating, Tracerting with VB

    Not easily. It's not hard to read a file and parse out the needed information.
    PING returns data even when it fails, so it'd be easy to parse. Other commands might take more work, but I'd bet it could be done.

  5. #5
    Addicted Member Paradox's Avatar
    Join Date
    Sep 2004
    Location
    Nairobi
    Posts
    189

    Re: Pinging, Netstating, Tracerting with VB

    Hey check out this Link great examples about pinging and great stuff
    Peny wise pound Foolish

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width