本帖最后由 pcl_test 于 2016-8-22 15:25 编辑
之前写过的一个VBS脚本,用Win32_NetworkAdapter获取系统的网卡信息,- Sub GetNic( argv )
- strComputer = "."
- Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
- Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter")
- Dim minobj
- minobj=Null
- aa=0
- ab=0
- StrRes=" "
- For Each objItem in colItems
- if Len(objItem.NetConnectionID)>2 and objItem.AdapterType="Ethernet 802.3" and InStr(objItem.NetConnectionStatus,"2") and InStr(objItem.PNPDeviceID,"PCI")>0 then
- StrRes= objItem.NetConnectionID & "," & objItem.MACAddress & "," & objItem.Description &","& objItem.PNPDeviceID
- If 4=argv Then Wscript.Echo StrRes
- if 0=ab Then
- ab=1
- Set minobj=objItem
- ElseIf StrComp(objItem.NetConnectionID,minobj.NetConnectionID)<0 Then
- set minobj=objItem
- end if
- end if
- Next
- Set objItem =minobj
复制代码 在window2008上运行没有问题,但是在windows2012上报错,提示(22,1)Microsoft VBScript运行时错误,缺少对象:‘minobj’
需要怎么修改呢,是不是2008和2012实现机制不一样
xuyao |