Re: ping all computer in lan...
- From: Shay Levi <no@xxxxxxxx>
- Date: Mon, 7 Apr 2008 18:53:53 +0000 (UTC)
Thanks!
-----
Shay Levi
$cript Fanatic
http://scriptolog.blogspot.com
"Shay Levi" <no@xxxxxxxx> wrote in message
news:8766a94426ca98ca66f329679e9e@xxxxxxxxxxxxxxxxxxxxx
HiYou can make your batch file just as granular:
You can use a DOS for loop, this will ping all computers (1-255) in
the 192.168.1.0 network (1 echo requests to send):
For /L %X In (1,1,255) Do ping -n 1 192.168.1.%X
WMI's ping class can be more granular:
subnet = "192.168.1."
for i=1 to 255
strHost = subnet &i
if Ping(strHost) = True then
Wscript.Echo "Host " & strHost & " is on-line"
Else
Wscript.Echo "Host " & strHost & " is off-line"
end if
next
Function Ping(strHost)
dim objPing, objRetStatus
set objPing =
GetObject("winmgmts:{impersonationLevel=impersonate}").ExecQuery _
("select * from Win32_PingStatus where address = '" & strHost & "'")
for each objRetStatus in objPing
if IsNull(objRetStatus.StatusCode) or objRetStatus.StatusCode < 0
then
Ping = False
'WScript.Echo "Status code is " & objRetStatus.StatusCode
else
Ping = True
end if
next
End Function
@echo off
For /L %%x In (1,1,255) Do
ping -n 1 192.168.1.%%x | find /i "bytes=" > nul
if ErrorLevel 1 (echo 192.168.1.%%x is off-line) else (echo
192.168.1.%%x
is on-line)
)
.
- Follow-Ups:
- Re: ping all computer in lan...
- From: Al Dunbar
- Re: ping all computer in lan...
- References:
- Re: ping all computer in lan...
- From: Pegasus \(MVP\)
- Re: ping all computer in lan...
- Prev by Date: Re: ping all computer in lan...
- Next by Date: Re: Setting Owner of an object.
- Previous by thread: Re: ping all computer in lan...
- Next by thread: Re: ping all computer in lan...
- Index(es):
Relevant Pages
|