'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'检测指定的IP是否通
'哈哈朱版权所有
'QQ:383088680
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Dim strURL
dim Count
dim i
dim j
j=0
Count=0
strURL=INputBox("看看你要查的这个IP是否能PING通:")
If Trim(strURL)<>"" then'如果输入的不为空就会执行下面
strURL=split(strURL,".")
FOR i=0 to Ubound(strURL)'循环显示每个IP字段是否符合格式,并且记录不能超过4个字段
j=j+1
if strURL(i)<0 or strURL(i)>255 then
Count=1
end if
Next
if j=4 then
if Count=0 then
'wscript.Echo "IP正确!"
NIP=strURL(0)&"."&strURL(1)&"."&strURL(2)&"."&strURL(3)'将数组IP结合起来
Set objPing = GetObject("winmgmts:{impersonationLevel=impersonate}")._
ExecQuery("select * from Win32_PingStatus where address = '"_
& NIP & "'")
For Each objStatus in objPing
If IsNull(objStatus.StatusCode) or objStatus.StatusCode<>0 Then
WScript.Echo("温馨提示: " & NIP & " 不能PING通啊!")
Else
Wscript.Echo "温馨提示:"&NIP&"能PING通啊!"
End If
Next
else
Wscript.Echo "温馨提示: " & NIP &"IP输入的不正确!"
End if
else
Wscript.Echo "温馨提示: " & NIP &"IP格式不正确!"
end if
else
Wscript.Echo "您放弃了要查询的功能!"
end if