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



Relevant Pages

  • Re: Dateien via Wildcards ermitteln
    ... mittels Wildcards in einem Pfad zu ermitteln sind. ... Set sh = CreateObject ... Const SHCONTF_FOLDERS = 32 'Ordner einbeziehn ... End If ...
    (microsoft.public.de.german.scripting.wsh)
  • Re: Windows Dienst (Starttyp) per script Qndern?=
    ... > Nachrichtendienst wieder Aktivieren soll. ... Const ADS_SERVICE_AUTO_START = 2 ... Set oWshNet = CreateObject ... End If ...
    (microsoft.public.de.german.scripting.wsh)
  • Re: Clients-Verfügbarkeit
    ... >Clients eingeschaltet sind (Test mittels Ping). ... Const OpenAsASCII = 0 ... Set objFSO = CreateObject ... End If ...
    (microsoft.public.de.german.scripting.wsh)
  • Re: suche nach Feldern in anderem Blatt
    ... Excel sollte nun nach Nachname und Vorname ... Const erste_zeile1 = 2 ... Set sh1 = Sheets ... End Sub ...
    (microsoft.public.de.excel)
  • Re: Share Berechtigungen auslesen
    ... Const FILE_TRAVERSE = &H20 ... End If ... If (oAce.AccessMask And FILE_TRAVERSE) 0 Then ...
    (microsoft.public.de.german.scripting.wsh)