-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPinger2.vbs
More file actions
31 lines (25 loc) · 710 Bytes
/
Copy pathPinger2.vbs
File metadata and controls
31 lines (25 loc) · 710 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Option Explicit
Dim oWMI, sSubnet, i, sHost
Dim sTarget, colItems, oItem, iTimeout
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
On Error Resume Next
iTimeout = 25
sSubnet = "192.168.1."
Set oWMI = GetObject("winmgmts:\\")
For i = 100 To 150
sHost = sSubnet & i
Pinger(sHost)
Next
Sub Pinger(sTarget)
Set colItems = oWMI.ExecQuery("Select * from Win32_PingStatus Where Address = '" & sTarget & "'" _
& "AND Timeout =" & iTimeout, "WQL", _
wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each oItem In colItems
If oItem.StatusCode = 0 Then
WScript.Echo sTarget & " --- ALIVE"
Else
WScript.Echo "XX " & sTarget & " XX"
End If
Next
End Sub