監(jiān)視網(wǎng)絡(luò)連接與斷開,特殊情況下可能有點用,兩個VBS腳本均來自微軟官網(wǎng)
監(jiān)視網(wǎng)絡(luò)連接:
代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery _
("Select * from MSNdis_StatusMediaConnect")
Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo "A network connection has been made:"
WScript.Echo strLatestEvent.InstanceName, Now
Wscript.Echo
Loop
監(jiān)視網(wǎng)絡(luò)斷開:
代碼如下:
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\wmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery("Select * from MSNdis_StatusMediaDisconnect")
Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wscript.Echo "A network connection has been lost:"
WScript.Echo strLatestEvent.InstanceName, Now
Loop
更多信息請查看IT技術(shù)專欄