IP地址没添对和网线断了导致上不去网有什么区别
比如一台机器上不去网了,有可能是IP没添对,有可能是病毒原因.这些都是软件上的,要是连电脑的网线断了 怎么能区别出来呢?都是ping不同 有没有什么函数或方法能区别开呢?麻烦大家了 一个网卡打X,一个不打 本帖最后由 smartzbs 于 2011-1-29 09:40 编辑
状态:0(未连接),2(连接),7(断线),11(地址非法)是你要的,也是常用的.
$sNetNmae = "本地连接";这里是你要监测的网卡名称
$strComputer = "."
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",Default,48)
While 1
For $objItem in $colItems
;ConsoleWrite($objItem.NetConnectionID & @CRLF)
If StringInStr($objItem.NetConnectionID, $sNetNmae, 1) Then
Switch $objItem.NetConnectionStatus
Case 0
$strStatus = "Disconnected"
Case 1
$strStatus = "Connecting"
Case 2
$strStatus = "Connected"
Case 3
$strStatus = "Disconnecting"
Case 4
$strStatus = "Hardware not present"
Case 5
$strStatus = "Hardware disabled"
Case 6
$strStatus = "Hardware malfunction"
Case 7
$strStatus = "Media disconnected"
Case 8
$strStatus = "Authenticating"
Case 9
$strStatus = "Authentication succeeded"
Case 10
$strStatus = "Authentication failed"
Case 11
$strStatus = "Invalid address"
Case 12
$strStatus = "Credentials required"
EndSwitch
TrayTip($objItem.NetConnectionID, $strStatus, 1)
$objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter",Default,48)
ExitLoop
EndIf
Next
;ExitLoop
WEnd 谢谢楼上的朋友 终于知道了 3楼高人哦哦。 有个API的函数,不记得了.
页:
[1]