×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

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!

*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

How can I check if a computer is connected without delay

How can I check if a computer is connected without delay

How can I check if a computer is connected without delay

(OP)
I am trying to check report files in a number of remote computers but if a computer is not switched on it takes forever.

My computer seems to freeze for a minute every time it cant connect for any reason.

I have tried opening the same file in every computer in turn (from a list) Eg - - - -

On error goto ComputerNotOn
For Item = 1 to 20
  Open "\\" & IPAddress(Item) & "\c\ReportFile.txt" for Input as #1
  Close #1
Next

Same using FileSystemObjects Getfile

But they all wait for a long long time when not connected.

Is there an instant way of seeing if a computer with a known IP address is there or not?
 

RE: How can I check if a computer is connected without delay

(OP)
One though I had is if I could do the same as ping from the command line and store the answer?
That would be a bit quicker but I would like it to be instant like using Wininet on the internet but how do you use that on just a LAN?

RE: How can I check if a computer is connected without delay

More WMI for you Ted ...

CODE

Public Function IsReachable(strComputer As String) As Boolean ' strComputer can be name or IP address
    Dim objWMIService As Object
    Dim objPing As Object
    Dim objStatus As Variant
    
    Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\.\root\cimv2")
    Set objPing = objWMIService.ExecQuery("Select * From Win32_PingStatus Where Address = '" & strComputer & "' and StatusCode=0")
    
    For Each objStatus In objPing
        IsReachable = objStatus.StatusCode = 0
    Next
End Function

RE: How can I check if a computer is connected without delay

(OP)
You are a genius
It only takes a second if the computer is not there

RE: How can I check if a computer is connected without delay

Thanks very much strongm... it really helps!

Take care
Mark

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! Already a Member? Login

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