首页 > 编程 > VBScript > 正文

一个查看局域网在线IP的vbs脚本

2020-07-26 11:55:08
字体:
来源:转载
供稿:网友
复制代码 代码如下:

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
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表