|
发表于 2011-3-4 11:07:34
|
显示全部楼层
$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 |
|