• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 254
  • Last Modified:

Finding network computer status more quickly

I am running a code that is querying a folder on all of my remote computers in order to see if the computer is turned on or off.

Now the code works perfectly, but when there is a computer turned off the timeout is very long.  I am wondering if there's a way I can speed up the process for failed computers.

Dim LastRow As String
    Dim i As Integer
    Dim Computer As String
    Dim fso As New FileSystemObject
    Dim d
    LastRow = Range("A65536").End(xlUp).Row
    On Error Resume Next
    For i = 1 To LastRow
            Computer = Range("A" & i & "").Value
            fso.GetFolder ("\\" & Computer & "\c$")
            If Err.Number <> 0 Then
                Cells(i, 2) = "Fail"
                Cells(i, 2) = "Good"
            End If
    Next i

Open in new window

1 Solution
ScotTFOAuthor Commented:
I have resolved this issue myself using:
Function SystemOnline(ByVal ComputerName As String)
    Dim colPingResults As Variant
    Dim oPingResult As Variant
    Dim strQuery As String
    strQuery = "SELECT * FROM Win32_PingStatus WHERE Address = '" & ComputerName & "'"
    Set colPingResults = GetObject("winmgmts://./root/cimv2").ExecQuery(strQuery)
    For Each oPingResult In colPingResults
        If Not IsObject(oPingResult) Then
            SystemOnline = False
        ElseIf oPingResult.StatusCode = 0 Then
            SystemOnline = True
            SystemOnline = False
        End If
End Function

Open in new window

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now