出现: ERROR:变量类型必须为对象类型("object")[己解决]
本帖最后由 tsmirs 于 2010-10-11 23:16 编辑Func _NetworkAdapterInfo()
Local $colItems = ""
Local $objWMIService
Local $NetworkAdapterID = 0
Local $NetworkAdapterName = ""
Local $NetworkAdapterGateway = ""
Local $NetworkAdapterHostName = ""
Local $NetworkAdapterIPaddress = ""
Local $NetworkAdapterDNS1 = ""
Local $NetworkAdapterDNS2 = ""
Local $NetworkAdapterSubnet = ""
Local $NetworkAdapterMAC = ""
Local $NetworkAdapterNetConnectionID = ""
Local $NetworkAdapterInfo ;最高10块网卡.
$NetworkAdapterInfo = 0
$objWMIService = ObjGet("winmgmts:\\localhost\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled != 0", "WQL", 0x10 + 0x20)
$colItem2 = $objWMIService.ExecQuery('SELECT * FROM Win32_NetworkAdapter WHERE NetConnectionStatus >0', "WQL", 0x10 + 0x20)
If IsObj($colItems) Then
For $objItem In $colItems
$NetworkAdapterName = $objItem.Description
$NetworkAdapterGateway = $objItem.DefaultIPGateway(0)
$NetworkAdapterHostName = $objItem.DNSHostName
$NetworkAdapterIPaddress = $objItem.IPAddress(0)
$NetworkAdapterDNS1 = $objItem.DNSServerSearchOrder(0)
$NetworkAdapterDNS2 = $objItem.DNSServerSearchOrder(1)
$NetworkAdapterSubnet = $objItem.IPSubnet(0)
$NetworkAdapterMAC = $objItem.MACAddress
$NetworkAdapterID += 1
$NetworkAdapterInfo = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterID
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterName
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterGateway
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterHostName
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterIPaddress
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterDNS1
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterDNS2
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterSubnet
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterMAC
Next
Else
Return $NetworkAdapterInfo
EndIf
If IsObj($colItem2) Then
$NetworkAdapterID = 0
For $objItem2s In $colItem2
$NetworkAdapterNetConnectionID = $objItem2s.NetConnectionID
$NetworkAdapterID += 1
$NetworkAdapterInfo[$NetworkAdapterID] = $NetworkAdapterNetConnectionID
Next
Return $NetworkAdapterInfo
Else
Return $NetworkAdapterInfo
EndIf
EndFunc ;==>_NetworkAdapterInfo
$info = _NetworkAdapterInfo()
MsgBox(4096, "测试",$info, 10)
这个脚本在WIN2000运行正常,WINXP运行后出现:ERROR:变量类型必须为对象类型("object") 怎么处理!!
请高手帮帮忙!! 我是XP,我这里正常啊 还是不行啊 Func _NetworkAdapterInfo()
Local $colItems = ""
Local $objWMIService
Local $NetworkAdapterID = ...
tsmirs 发表于 2010-2-10 17:22 http://www.autoitx.com/images/common/back.gif
系统可能是精简版,autoit找不到指定wmi信息 :face (12): :face (22): 是系统问题,谢谢大家,系统重装下解决了 我晕,不用重装系统的,把你的系统服务恢复成默认就OK了~~~我之前也遇到这个问题~~~
页:
[1]