Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Network Down?

Posted on 1998-08-01
4
Medium Priority
?
149 Views
Last Modified: 2010-05-03
There are 5 NTs networked on tcp/ip,at my machine i'm trying to have an application run in the background that will tell me when any of these machines are disconnected from the network? Im newbie so be very detailed thanks
0
Comment
Question by:jbird090897
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 
LVL 2

Expert Comment

by:shchuka
ID: 1467472
One possible solution is to have a timer in VB and in its timer event ping each of the machines, i.e. send something to it and get a responce.  If a machine doesn't respond within some established period of time (say, 5 seconds), you can assume it's off the network.

The pitfall is, though, you need to make sure that the timer interval is longer than the time your whole routine need to execute.  Otherwise, disable the timer in the beginning of the subroutine and enable it again at the end.
0
 

Author Comment

by:jbird090897
ID: 1467473
ok sounds good how do i do that code wise
0
 
LVL 2

Expert Comment

by:percosolator
ID: 1467474
easiest way to do it (and least elegant) would be to execute a shell command that pings the server, redirect that output into a file and parse the file for a "Request Timed Out" message, if not found, wipe the file and proceed to the next file.

"Ping 209.123.34.1 > C:\Replies.Txt"

Or, maybe someone else could tell you how to check using a more direct means.



0
 
LVL 1

Accepted Solution

by:
jf26028 earned 400 total points
ID: 1467475
This is the code that they mentioned in the above comments:


Form1 contains:

Timer1
List1



'This is the code in the form:


Private Sub Timer1_Timer()
    Dim I As Integer    'counter variable
       
    List1.Clear         'erase the last responses
       
        'for all the machines, check to see if they are
        'responding
       
    For I = 1 To 5
        FindMachine Machines(I)
    Next
   
End Sub


'that is all for the form




'this is in a module with a sub main().  Sub main must
'be the startup object.  Set this by pressing alt + p and
'alt + e, the change the startup object from form1 to sub main

Option Explicit

'global array of computer names to ping
Global Machines(1 To 5) As String
   
Public Sub main()


    'populate the array with the computer names
    'you change each of these for your own use
    Machines(1) = "Computer1"
    Machines(2) = "Computer2"
    Machines(3) = "Computer3"
    Machines(4) = "Computer4"
    Machines(5) = "Computer5"
       
    Form1.Show
   
   
End Sub
   
   
Public Sub FindMachine(MachineName As String)
        'string used to search the output file
    Dim InString As String
        'temp long to hold response from Shell()
    Dim Temp As Long
   
        'this is the batch file you will shell
    Open "c:\temp\runthis.bat" For Output As #1
    Print #1, "ping " & MachineName & " > c:\temp\output.tmp"
        'eof.tmp is a temp file used to know when the ping process is done
    Print #1, "del c:\temp\eof.tmp"
    Close #1
   
        'copy the temp file to delete later
    FileCopy "c:\temp\runthis.bat", "c:\temp\eof.tmp"
        'shell the ping
    Temp = Shell("c:\temp\runthis.bat", vbHide)
        'wait until the process if finished
    While Dir("c:\temp\eof.tmp") <> ""
        DoEvents
    Wend
        'parse the file
    Open "c:\temp\output.tmp" For Input As #1
    While Not EOF(1)
        Line Input #1, InString
            'if reply is in the file, then the machine responded
        If InStr(InString, "Reply") Then
            Form1.List1.AddItem "Machine " & MachineName & " Online"
            Close #1
                'response found, exit
            Exit Sub
        End If
    Wend
        'if "reply" not found in the file, then the machine did not
        'respond and is offline
    Close #1
    Form1.List1.AddItem "Machine " & MachineName & " Offline"
End Sub



'end of code.

You need to set Timer1.Interval to whatever you want the interval
between checking the computers to be.

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question