How to fing ping via VBA?

H

hanski

hi

I would like to know in my code if a certain computer is on or off and
continue then forward depending on the answer.

How it is possible to find out if the computer is online or offline
via VBA?

hanski
 
D

David-W-Fenton

m:
How it is possible to find out if the computer is online or
offline via VBA?

You can check to see if a known named resource is available. If you
know the computer name and a share that has files in it, you could
check:

Dir("\\ComputerName\ShareName\*.*")

....if that doesn't error out, you know it's there and accessible. Of
course, if it's not, throws an error, and then you have to
distinguish which particular errors.

You could also use the File System Object, something like this:

Dim objFSO as Object

Set objFSO = CreateObject("Scripting.FileSystemObject")
If objFSO.FileExists(strFileName) Then
Debug.Print strFileName & " exits."
End If

I pulled that from code I already have that's more complicated. It
has the advantage of not causing an error if the remote machine is
not accessible. It does take longer when the machine is inaccessible
than when it's not, but that should be OK.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top