标题:问一个VSB的问题
只看楼主
ZEROBLUES
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-31
 问题点数:0 回复次数:1 
问一个VSB的问题
小弟初学者,最近在写一段PING IP和输出PC信息的VBS脚本,现在成果如下
PING IP的脚本
strSubNet = "10.10.1."
Set objFSO= CreateObject("Scripting.FileSystemObject")
Set objTS = objfso.CreateTextFile("d: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
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


然后这个是输出PC信息的
strComputer = "10.10.1.50"
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter")

For Each objItem in colItems
    'If objItem.PhysicalAdapter Then
        Wscript.Echo "Name: " & objItem.Name
        Wscript.Echo "Manufacturer: " & objItem.Manufacturer
        Wscript.Echo "MACAddress: " & objItem.MACAddress
        Wscript.Echo "AdapterType: " & objItem.AdapterType
        Wscript.Echo "Status: " & objItem.Status
        Wscript.Echo "SystemName: " & objItem.SystemName
        Wscript.Echo "Description: " & objItem.Description
        Wscript.Echo
    'End If
Next


但是不知道怎么把2个代码并起来,我的意图在于在一个程序里做2个功能,就是自动PING 局域网里(公司内部所有电脑)IP一个一个ping下来,ping成功的就输出PC的部分信息,不成功的就跳过,望大神们指导下!
搜索更多相关主题的帖子: success 信息 
2013-06-05 08:29
ZEROBLUES
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2013-5-31
得分:0 
没高手回答啊,小弟急啊
2013-06-08 08:21



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-414550-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 1.068855 second(s), 7 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved