一个查看局域网在线IP的vbs脚本
程序员文章站
2022-04-29 09:18:08
复制代码 代码如下:strsubnet = "192.168.1." set objfso= createobject("scripting.filesystemobjec...
复制代码 代码如下:
strsubnet = "192.168.1."
set objfso= createobject("scripting.filesystemobject")
set objts = objfso.createtextfile("e:\pingresult.txt")
for i = 1 to 254
strcomputer = strsubnet & i
blnresult = ping(strcomputer)
if blnresult = true then
objts.writeline "ping " & strcomputer & " success!"
end if
next
objts.close
wscript.echo "done!"
function ping(strcomputer)
set objwmiservice = getobject("winmgmts:\\.\root\cimv2")
set colitems = objwmiservice.execquery("select * from win32_pingstatus where address='" & strcomputer & "'")
for each objitem in colitems
select case objitem.statuscode
case 0
ping = true
case else
ping = false
end select
exit for
next
end function
上一篇: vbs版IP地理位置查询小偷
下一篇: VBS编程教程 (第2篇)