code:
break on
call \\server\logon\udf.kix
dim $namearray[2,1]
$ip1 ="195.151.234.1"
$sn1 ="255.255.255.128"
$iparray=IPRange($ip1,$sn1)
$index=0
for each $ip in $iparray
? "$ip "
if $ip
$hostname=lookup($ip)
if not @error
"$hostname $index"
$namearray[0,$index]=$hostname
$namearray[1,$index]=$ip
$index=$index+1
redim preserve $namearray[2,$index]
else
$p=WSHPing($ip)
if $p[1]=1
"IP Active"
else
"No Reply"
endif
endif
endif
next
redim preserve $namearray[2,$index-1]
:l
for $loop=0 to ubound($namearray,2)
$computer =$namearray[0,$loop]
$ipaddr =$namearray[1,$loop]
$ping =""
$remoteuser=""
if $computer
$p=WSHPing($ipaddr)
$ip=$p[0]
$ping=$p[1]
endif
if $ping=1
$remoteuser=wmiquery("UserName","Win32_ComputerSystem",$computer)
$color="color b+/n"
$bootTime=wmiquery("LastBootUpTime","Win32_OperatingSystem",$computer)
if $boottime
$boot=ConvertFromWMIDate($boottime)
endif
endif
if $remoteuser=""
select
case $ip= "0.0.0.0" $remoteuser="unknown " $color="color w/n"
case $ping=-1 $remoteuser="Down " $color="color r+/n"
case 1 $remoteuser="On-line " $color="color g+/n"
endselect
endif
if len($computer)<8 $computer="$computer " endif
if $ip= "0.0.0.0" $ip= "0.0.0.0 " endif
$_=execute("? '$$computer $$ip '$color $$remoteuser color w/n' '$$boot")
next
?
sleep 30
goto l
exit
Function IPRange($sIPaddress,$sNetMask)
Dim $aiStartRange,$aiMaskBits,$aiEndRange[4],$iHostCount,$i
Dim $iOctet1,$iOctet2,$iOctet3,$iOctet4
Dim $tempArray[1]
$iHostCount=1
$aiStartRange=Split($sIPaddress,".")
$aiMaskBits=Split($sNetMask,".")
Redim Preserve $aiStartRange[4]
Redim Preserve $aiMaskBits[4]
For $i = 0 To 3
$aiMaskBits[$i] =Val($aiMaskBits[$i]) & 255
$aiStartRange[$i] =Val($aiStartRange[$i]) & $aiMaskBits[$i]
$aiEndRange[$i] =$aiStartRange[$i]+(255-$aiMaskBits[$i])
$iHostCount =$iHostCount*($aiEndRange[$i]-$aiStartRange[$i]+1)
Next
redim $temparray[$iHostCount]
$i=0
For $iOctet1 = $aiStartRange[0] To $aiEndRange[0]
For $iOctet2 = $aiStartRange[1] To $aiEndRange[1]
For $iOctet3 = $aiStartRange[2] To $aiEndRange[2]
For $iOctet4 = $aiStartRange[3] To $aiEndRange[3]
$temparray[$i]="$iOctet1.$iOctet2.$iOctet3.$iOctet4"
$i=$i+1
Next
Next
Next
Next
$IPRange=$temparray
EndFunction
function ConvertFromWMIDate($wmidate)
if instr($wmidate,'.')
$ConvertFromWMIDate=left($wmidate,4)+'/'+substr($wmidate,5,2)+'/'+substr($wmidate,7,2)+' '
$ConvertFromWMIDate=$ConvertFromWMIDate+substr($wmidate,9,2)+':'+substr($wmidate,11,2)+':'+substr($wmidate,13,2)
else
$ConvertFromWMIDate=''
endif
endfunction
[ 18. November 2002, 20:56: Message edited by: Radimus ]