strMachines = "127.0.0.1"
strMachines2 = ";64.226.23.162;www.daconsult.com"
intGatewayCount = 0

strComputer = "."

Set objWMIService = GetObject("winmgmts:" _
    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'Check for the TCP/IP Protocol
Set colItems = objWMIService.ExecQuery _
    ("Select * from Win32_NetworkProtocol")

blnTCPIPInstalled = False

For Each objItem in colItems
    If UCase(objItem.Caption) = "TCPIP" Then
       blnTCPIPInstalled = True
    End If
Next

If blnTCPIPInstalled Then
   Set colAdapters = objWMIService.ExecQuery _
       ("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = True")

   For Each objAdapter in colAdapters
      If Not IsNull(objAdapter.IPAddress) Then
         If Not IsNull(objAdapter.DefaultIPGateway) Then
            For i = 0 To UBound(objAdapter.DefaultIPGateway)
               strMachines = strMachines & ";" & objAdapter.DefaultIPGateway(i)
	       intGatewayCount = intGatewayCount + 1
            Next
         End If
      End If 
   Next
 
   if intGatewayCount > 0 Then
      'Script Starts Here
      strMachines = strMachines & strMachines2
      'wscript.echo strMachines
      aMachines = split(strMachines, ";")
      strStatus = "Script Complete:"
      CRLF = chr(13) & chr(10)
 
      For Each machine in aMachines
          Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
              ExecQuery("select * from Win32_PingStatus where address = '"_
                  & machine & "'")
          For Each objStatus in objPing
              If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then 
                  strStatus = strStatus & CRLF & "Computer " & machine & " is not reachable."
	          If machine = "127.0.0.1" Then
		      strStatus = strStatus & CRLF & "(TCP/IP is not set properly)"
   	          End If
	          If machine = "www.daconsult.com" Then
		      strStatus = strStatus & CRLF & "(DNS Resolution Error)"
	          End If
	          If machine = "209.35.223.29" Then
		      strStatus = strStatus & CRLF & "(Internet not visible)"
	          End If
	          If machine <> "127.0.0.1" And machine <> "209.35.223.29" And machine <> "www.daconsult.com" Then
		      strStatus = strStatus & CRLF & "(LAN Error, Gateway not visible)"
	          End If
              End If
          Next
      Next
      If strStatus = "Script Complete:" Then
         strStatus = strStatus & CRLF & "All Computers Reached." & CRLF & "Your networking settings are OK."
      End If
      WScript.Echo(strStatus)
   Else
      WScript.Echo("No Active Internet Connection Detected. Please connect to the Internet before running this script.")  
   End If
Else
   'TCP/IP Not Installed
   WScript.Echo("TCP/IP is not installed.")
End If

