Mich tippte:
[Skript]
Um ein einheitliches Erscheinungsbild des Protokolls auch beim Aufruf
von Domain-Namen zu gewährleisten, mussten leider noch einige
Ergänzungen gemacht werden. Dies ist nun die Release-Wörschen:
'########################### CheckIP.vbs #############################
' von h.r.roesler
Option Explicit
' Pingt alle 15 Sekunden eine IP-Adresse. Wird keine Adresse als
' Argument übergeben, wird die voreingestellte Adresse verwendet.
' Es kann auch eine Domain angegeben werden (z. B.
example.com).
' Die Ausgabe kann in eine Textdatei umgeleitet werden.
' Es wird die Nicht-Erreichbarkeit eines Hosts protokolliert.
' Das Skript muss in der Eingabeaufforderung ausgeführt werden:
' CScript.exe [Pfad]CheckIP.vbs [IP-Adresse] [> Dateiname]
Const WINMGT = "winmgmts:{impersonationLevel=impersonate}!root/cimv2"
Dim wmi, Echo, wshShell, strHost, blnBooze, str
Set wmi = GetObject(WINMGT)
Set Echo = WScript.StdOut
Set wshShell = CreateObject("WScript.Shell")
strHost = "8.8.8.8" '
google-public-dns-a.google.com
If WScript.Arguments.Count > 0 Then strHost = WScript.Arguments(0)
Do ' Pingt alle 15 Sekunden die IP-Adresse
If Ping(strHost, Not(blnBooze), str) Then
WScript.Sleep 60000 \ 4
If Not(blnBooze) Then blnBooze = True
Else
If blnBooze Then wshShell.Exec "ipconfig.exe /flushdns"
WScript.Sleep 1000
If blnBooze Then blnBooze = False
End If
Loop
Function Ping(ByRef strIP, blnSip, ByRef strFormerMsg)
Dim wmiPing, blnPong, strQuery, str
strQuery = "select * from Win32_PingStatus where " & _
"ResolveAddressNames = True And Address='" & strIP & "'"
For Each wmiPing In wmi.ExecQuery(strQuery)
If IsNull(wmiPing.StatusCode) Then str = Now & " Null": Exit For
blnPong = wmiPing.StatusCode = 0
If Not(IsNumeric(strIP)) Then
If IsNumeric(wmiPing.ProtocolAddress) Then
strIP = wmiPing.ProtocolAddress
End If
End If
str = Now & " Checking " & wmiPing.ProtocolAddressResolved & _
" [" & strIP & "]: " & Eval(wmiPing.StatusCode)
Next
If Not(blnPong) Or blnSip Then
If Not(blnPong) And Len(strFormerMsg) > 0 Then
Echo.WriteLine strFormerMsg
strFormerMsg = ""
End If
Echo.WriteLine str
Else
strFormerMsg = str
End If
Ping = blnPong
End Function
Function Eval(lngNumber)
Dim arr
arr = Array("Success", "Buffer Too Small", "Destination Net" & _
" Unreachable", "Destination Host Unreachable", _
"Destination Protocol Unreachable", "Destination Port" & _
" Unreachable", "No Resources", "Bad Option", "Hard" & _
"ware Error", "Packet Too Big", "Request Timed Out", _
"Bad Request", "Bad Route", "TimeToLive Expired Transit", _
"TimeToLive Expired Reassembly", "Parameter Problem", _
"Source Quench", "Option Too Big", "Bad Destination")
ReDim Preserve arr(50)
arr(32) = "Negotiating IPSEC": arr(50) = "General Failure"
If lngNumber > 11000 Then lngNumber = lngNumber - 11000
Eval = arr(lngNumber)