T O P I C R E V I E W |
1029usr078198 |
Posted - December 29 2007 : 10:37:35 Here's a Visual Basic, Scripting Edition version of a "Ping Sweep". A ping sweep finds all the IP addresses in use in a particular range.
Here's the code:
On Error Resume Next
intStartingAddress = 1 intEndingAddress = 100 strSubnet = "192.168.3."
For i = intStartingAddress to intEndingAddress strComputer = strSubnet & i
Set objShell = CreateObject("WScript.Shell") strCommand = "%comspec% /c ping -n 3 -w 1000 " & strComputer & "" Set objExecObject = objShell.Exec(strCommand)
Do While Not objExecObject.StdOut.AtEndOfStream strText = objExecObject.StdOut.ReadAll() If Instr(strText, "Reply") > 0 Then
' ===================================================================== ' Insert your code here ' =====================================================================
Set objWMIService = GetObject _ ("winmgmts:\\" & strComputer & "\root\cimv2") Set colItems = objWMIService.ExecQuery _ ("Select * From Win32_OperatingSystem") For Each objItem in ColItems Wscript.Echo strComputer & ": " & objItem.Caption Next
' ===================================================================== ' End ' =====================================================================
Else Wscript.Echo strComputer & " could not be reached." End If Loop Next
Hope it helps, David |
|
|