fabmin
Goto Top

VBScript - WshShell.Popup

Wie bekomm ich das verdammte Popup hin?

<font class = code>
On Error Resume Next

strComputer = "."
arrTargets = Array("172.27.2.1",".","zbw2knb38",".","zbw2ksv01")

Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

For Each strTarget In arrTargets

Set colPings = objWMIService.ExecQuery _
("Select * From Win32_PingStatus where Address = '" & strTarget & "'")
If Err = 0 Then
Err.Clear
For Each objPing In colPings
If objPing.StatusCode = 0 Then
WScript.Echo vbCrLf & strTarget & " responded to ping."
WScript.Echo "Responding Address: " & objPing.ProtocolAddress
WScript.Echo "Responding Name: " & objPing.ProtocolAddressResolved
WScript.Echo "Bytes Sent: " & objPing.BufferSize
WScript.Echo "Time: " & objPing.ResponseTime & " ms"
WScript.Echo "TTL: " & objPing.ResponseTimeToLive & " seconds"
GetName
Else
'*WScript.Echo vbCrLf & strTarget & " did not respond to ping."
'*WScript.Echo "Status Code: " & objPing.StatusCode
End If
Next
Else
Err.Clear
If ExecPing = True Then
GetName
End If
End If
Next

'

Function ExecPing

Set objShell = CreateObject("WScript.Shell")
Set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
If InStr(strPingResults, "reply from") Then
WScript.Echo vbCrLf & strTarget & " responded to ping."
ExecPing = True
Else
'*WScript.Echo vbCrLf & strTarget & " did not respond to ping."
ExecPing = False
End If

End Function

'


Sub GetName

Err.Clear
Set objWMIServiceRemote = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strTarget & "\root\cimv2")
If Err = 0 Then
Err.Clear
Set colCompSystems = objWMIServiceRemote.ExecQuery("SELECT * FROM " & _
"Win32_ComputerSystem")
For Each objCompSystem In colCompSystems
WScript.Echo "Host Name: " & LCase(objCompSystem.Name)
Next
Else
Err.Clear
WScript.Echo "Unable to connect to WMI on " & strTarget & "."
End If

End Sub
</font>

Ich möchte, dass er am Ende eine WshShell.Popup oder MsgBox mit folgender Zusammenfassung ausgibt.
--> Hostname, IP Adresse, Ping (ms) bzw. nicht erreichbar
Über eure Hilfe freue ich mich wie immer face-smile

Content-ID: 15999

Url: https://administrator.de/contentid/15999

Ausgedruckt am: 21.11.2024 um 21:11 Uhr