DAConsult Forums
DAConsult Forums
Home | Profile | Register | Active Topics | Members | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Windows
 Small Business Server
 Ping Sweep Script
 New Topic  Reply to Topic
 Send Topic to a Friend
 Printer Friendly
Author Previous Topic Topic   

1029usr078198
Forum Admin

USA
333 Posts

Posted - December 29 2007 :  10:37:35  Show Profile  Email Poster  Visit 1029usr078198's Homepage  Click to see 1029usr078198's MSN Messenger address  Reply with Quote
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
  Previous Topic Topic   
 New Topic  Reply to Topic
 Send Topic to a Friend
 Printer Friendly
Jump To:
DAConsult Forums © 2007-2010 David Anderson Consulting Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000 Version 3.4.06