-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreate Clients List.vbs
More file actions
36 lines (33 loc) · 1.49 KB
/
Copy pathCreate Clients List.vbs
File metadata and controls
36 lines (33 loc) · 1.49 KB
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
32
33
34
35
36
'--------------------------------------------------------------------
'* Creates a Clients.txt file in the root of the C: drive
'* containing the names of all systems within the
'* subnet that responded to a ping.
'*
'* Shawn Stugart
'*
'* Last Modified 04/14/2004
'===================================================================
Option Explicit
Dim intIPSubnet, oFSO, oShell, oClientsTxt, i, j, k, oScriptExec1
Dim strPingStdOut1, oScriptExec2, strPingStdOut2, strClient
WScript.StdOut.Write("Enter starting host ID to scan: ")
j = WScript.StdIn.ReadLine
WScript.StdOut.Write("Enter ending host ID to scan: ")
k = WScript.StdIn.ReadLine
WScript.StdOut.Write("Enter network ID (For example, 192.168.1.): ")
intIPSubnet = WScript.StdIn.Readline
Set oFSO = CreateObject("Scripting.FileSystemObject")
Set oShell = CreateObject("WScript.Shell")
Set oClientsTxt = oFSO.CreateTextFile("C:\Clients.txt", True)
For i = j To k
set oScriptExec1 = oShell.Exec("ping -n 1 -w 10 " & intIPSubnet & i)
WScript.Echo "Pinging " & intIPSubnet & i
strPingStdOut1 = Lcase(oScriptExec1.StdOut.ReadAll)
If InStr(strPingStdOut1, "reply from ") Then
set oScriptExec2 = oShell.Exec("ping -a -n 1 -w 25 " & intIPSubnet & i)
oScriptExec2.StdOut.SkipLine
strPingStdOut2 = Lcase(oScriptExec2.StdOut.ReadLine)
strClient = Split(strPingStdOut2," ",3,1)
oClientsTxt.WriteLine(strClient(1))
End If
Next