Clients-Verfügbarkeit

From: Christoph Fricke (anonymous_at_discussions.microsoft.com)
Date: 06/01/04


Date: Tue, 1 Jun 2004 02:30:57 -0700

Hi there,

>-----Originalnachricht-----
>Hallo!
>
>Hat gerade jemand ein paar Zeilen für mich, damit ich
ermitteln kann welche
>Clients eingeschaltet sind (Test mittels Ping). Ip-
Bereiche sollen aus einer
>Textdatei gelesen werden, wobei ich nur 10.10.10 angeben
möchte und er dann
>automatisch mit .1 - .254 ergänzt
>
>Sascha Teuber
>

Const ForReading = 1
Const OpenAsASCII = 0
Const OverwriteIfExist = -1

Set objFSO = CreateObject("Scripting.FileSystemObject")

Set fResultFile = objFSO.CreateTextFile
("c:\pingresult.txt", _
                    OverwriteIfExist, OpenAsASCII)

Set objInputFile = objFSO.OpenTextFile("C:\ping.txt",
ForReading)
arrIpList = Split(objInputFile.ReadAll, vbCrLf)
objInputFile.Close

For l = 0 To UBound(arrIpList)
  strIP = Trim(arrIpList(l))
  If strIP <> "" Then
    If Not IsConnectible(strIP, "", "") Then
      fResultFile.WriteLine strIP & " is down"
    End If
  End If
Next

Function IsConnectible(sHost, iPings, iTO)

  Const OpenAsASCII = 0
  Const FailIfNotExist = 0
  Const ForReading = 1
  Dim oShell, oFSO, sTempFile, fFile

  If iPings = "" Then iPings = 2
  If iTO = "" Then iTO = 750

  Set oShell = CreateObject("WScript.Shell")
  Set oFSO = CreateObject("Scripting.FileSystemObject")

  sTempFile = oFSO.GetSpecialFolder(2).ShortPath & "\" &
oFSO.GetTempName

  oShell.Run "%comspec% /c ping.exe -n " & iPings & " -
w " & iTO _
     & " " & sHost & ">" & sTempFile, 0 , True

  Set fFile = oFSO.OpenTextFile(sTempFile, ForReading, _
                                    FailIfNotExist,
OpenAsASCII)

  Select Case InStr(fFile.ReadAll, "TTL=")
    Case 0 IsConnectible = False
    Case Else IsConnectible = True
  End Select

  fFile.Close
  oFSO.DeleteFile(sTempFile)

End Function

Gruß
Christoph