今后请发表你已经得到和审判。 这里是一个测试脚本
function get_ip(strTarget)
set objShell = CreateObject("WScript.Shell")
set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
get_ip = ""
if InStr(strPingResults, "reply from") then
wscript.echo VbCrLf & strTarget & " responded to ping."
set regEx = New RegExp
regEx.Pattern = "\b\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\b"
set matches = regEx.Execute(strPingResults)
if matches.count > 0 then
get_ip = matches(0)
end if
else
wscript.echo vbCrLf & strTarget & " did not respond to ping."
wscript.quit 1
end If
end function
function is_online(strTarget)
set objShell = CreateObject("WScript.Shell")
set objExec = objShell.Exec("ping -n 2 -w 1000 " & strTarget)
strPingResults = LCase(objExec.StdOut.ReadAll)
if inStr(strPingResults, "reply from") then
is_online = true
else
is_online = false
end If
end function
pcname = inputbox("Give the pc-name to ping:")
ip = get_ip(pcname)
wscript.echo "ip of pc " & pcname & " is " & ip
aIp = split(ip, ".")
aIp(2) = 1
router = join(aIp, ".")
wscript.echo "pinging " & router
if is_online(strTarget) then
wscript.echo "router is online"
else
wscript.echo "router is offline"
end if
你有每个网站的netblocks的地图?他们是否都统一使用路由器地址的块中的第一个IP?如果没有,这是不可行的(如果是的话,一些示例网块定义将会有所帮助)。或者,10.x.x.x示例只是一个占位符,表示实际块中的公共地址是什么?或者,您的网络是否完全分割为10.x.x.x空间中的/ 16? – tripleee 2012-07-21 12:58:27