×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

check for network connection - SLOW!

check for network connection - SLOW!

check for network connection - SLOW!

(OP)
I modified this from an Internet Search. It tests to see if the user is connected to a company network. It works, but the first time I run it, whether connected to network or not, it takes about 27 seconds - VERY SLOW! Then each time, it is almost instant. Anyway to speed the initial runtime up?

CODE --> vba

Sub checkmynetwork()
 
Set objFSO = CreateObject("Scripting.FileSystemObject")

    If objFSO.FolderExists("\\24.224.224.224\DATA\HOME") Then    
            MsgBox "Connected to network, Use Internal IP Address"      
    Else    
            MsgBox "Not connected to network, Use External IP Address"         
         
    End If


End Sub 

I've also tried this, which seems to do a little better, but still long delay on first attempt:

CODE --> vba

Sub checkmynetwork2()

    Dim FSO As Scripting.FileSystemObject
    Dim FolderPath As String

    Set FSO = New Scripting.FileSystemObject

    FolderPath = "F:\HOME\"
    If Right(FolderPath, 1) <> "\" Then
        FolderPath = FolderPath & "\"
    End If

    If FSO.FolderExists(FolderPath) = False Then
        MsgBox "Not connected to network, Use External IP Address"
    Else
        MsgBox "Connected to network, Use Internal IP Address"
    End If

End Sub 

RE: check for network connection - SLOW!

I see your problem. Your LAN server is in a routable IP range. That is the internal IP of your server (24.224.224.224) is routable on the internet. IP's that begin "10." or "192.168." are not routable and common for small office Lan's. Bigger networks can't do this and instead use a proxy server to get to the Internet. Out of the office, your computer is likely trying to bug some computer on the Internet for information. So all that said, I think your method is fundamentally flawed for your circumstance.

That said I do not have a good answer. Anything that tries to reach an unreachable network is going to take time to fail.

You want something that has a quick response, and something there is an example of how to do that via VBA. I briefly thought setting an environment variable during logon and checking with environ() would work but then I realized it would stay set until boot which could be AFTER a disconnect. You could maybe check such a variable first and then only do a long to fail test if set (find something that is not a bad Internet citizen). It may speed things up in some/most cases. If that works, you need IT to do something at logon or give you a value you can check. Likely they won't add something but maybe there is something you can check.

Maybe you could do a direct DNS lookup to your server name somehow via vba? It had better use a fully qualified domain name that your company owns the root domain for or you could end up in a spoofing situation.

Anyway if you solve it with this nudge in the right direction, let us know.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close