求一个能自动检测网卡网关IP然后对其ping测试,及时显示ping结果状态的代码。如下是找到网卡网关IP但不知如何对其ping测试,希望高人相助!!!!
$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItem ...
songqi_z 发表于 2009-9-13 21:16
加上ping不就行了$objWMIService = ObjGet("winmgmts:\\.\root\CIMV2")
$colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapterConfiguration WHERE IPEnabled = TRUE", "WQL", 0x10 + 0x20)
For $objItem In $colItems
$IPGateway = $objItem.DefaultIPGateway(0)
Next
$IPGateway = StringRegExpReplace($IPGateway, '(\d+\.){12}', '')
Dim $sResult
$iPid = Run("ping " & $IPGateway, "", 0, 3)
While 1
$sLine = StdoutRead($iPid)
If @error Then ExitLoop
$sResult &= $sLine
WEnd
MsgBox(0, "ping " & $IPGateway, $sResult)
|