Вместо того, чтобы смотреть на файл со списком IP-адресов, я хочу, чтобы он смотрел на диапазон. Диапазон должен быть таким же большим, как у класса C. Может ли кто-нибудь помочь мне отредактировать приведенный ниже код, чтобы добиться этого? Я пытаюсь найти 10.0.0.0 с маской подсети 255.255.0.0.
' NetworkFindInfo.vbs - Windows Logon Script.
' VBScript - Look up a computers info.
' Author Chris Collins
' Version 1 - July 2018
' ----------------------------------------------------------'
Option Explicit
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
Const PATH_TO_INPUT = "C:\Users\ccollins\Desktop\NetworkFindingInfo\ComputerList.txt"
Const PATH_TO_OUTPUT = "C:\Users\ccollins\Desktop\NetworkFindingInfo\ComputerInfo.csv"
Dim fso
Set fso = WScript.CreateObject("Scripting.FileSystemObject")
Dim shl
Set shl = WScript.CreateObject("WScript.Shell")
Dim input
Set input = fso.OpenTextFile(PATH_TO_INPUT)
Dim output
Set output = fso.CreateTextFile(PATH_TO_OUTPUT, True)
output.WriteLine "Hostname,Computer Name,Domain,Serial Number,Make,Model,BIOS Version,Operating System,CPU,Memory (MB),Disk Drives,MAC Address"
Dim wmiService
Dim wmiResults
Dim hostname
Dim computername
Dim domain
Dim make
Dim model
Dim biosversion
Dim operatingSystem
Dim serialNumber
Dim cpu
Dim memory
Dim drives
Dim mac
Dim line
Dim exec
Dim pingResults
While Not input.AtEndOfStream
line = input.ReadLine
hostname = ""
computername = ""
domain = ""
make = ""
model = ""
biosversion = ""
operatingSystem = ""
serialNumber = ""
cpu = ""
memory = ""
drives = ""
mac = ""
Set exec = shl.Exec("ping -n 2 -w 1000 " & line)
pingResults = LCase(exec.StdOut.ReadAll)
If InStr(pingResults, "reply from") Then
On Error Resume Next
Set wmiService = GetObject("winmgmts:\\" & line & "\root\CIMV2")
If Not Err.Number = 0 Then
output.WriteLine line & ",Error: " & Err.Description
On Error GoTo 0
Else
On Error GoTo 0
hostname = line
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_BIOS", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
Dim item
For Each item In wmiResults
serialNumber = Trim(item.SerialNumber)
biosversion = Trim(item.SMBIOSBIOSVersion)
Next
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In wmiResults
make = Trim(item.Manufacturer)
model = Trim(item.Model)
computername = Trim(item.Name)
domain = Trim(item.Domain)
Next
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_OperatingSystem", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In wmiResults
operatingSystem = Trim(item.Name)
operatingSystem = Split(operatingSystem, "|")(0)
memory = Round(Trim(item.TotalVisibleMemorySize) / 1024, 2)
Next
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_Processor", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In wmiResults
cpu = Trim(item.Name)
Next
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_NetworkAdapter WHERE PhysicalAdapter = 1", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In wmiResults
mac = Trim(item.MACAddress)
Next
Set wmiResults = wmiService.ExecQuery("SELECT * FROM Win32_LogicalDisk WHERE DriveType=3", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
For Each item In wmiResults
drives = drives & Trim(item.DeviceID) & " " & Round(Trim(item.Size) / (1024^2), 2) & ";"
Next
output.WriteLine hostname & "," & computername & "," & domain & "," & serialNumber & "," & make & "," & model & "," & biosversion & "," & operatingSystem & "," & cpu & "," & memory & "," & drives & "," & mac
End If
Else
output.WriteLine line & ",No Response"
End If
Wend
output.Close
input.Close
Set wmiService = Nothing
Set wmiresults = Nothing
Msgbox("Done Collecting Data")
Кроме того, в моей сети есть определенные IP-адреса, на которых этот код останавливается. Есть ли способ сохранить его работоспособным?