VBS監(jiān)視網(wǎng)絡(luò)連接與斷開的代碼
監(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
相關(guān)文章
用vbs實現(xiàn)枚舉網(wǎng)絡(luò)連接的代碼
用vbs實現(xiàn)枚舉網(wǎng)絡(luò)連接的代碼...2007-05-05用vbs實現(xiàn)隨機讀取文件的一行內(nèi)容的腳本
用vbs實現(xiàn)隨機讀取文件的一行內(nèi)容的腳本...2007-10-10用vbs讀取index.dat內(nèi)容的實現(xiàn)代碼
用vbs讀取index.dat內(nèi)容的實現(xiàn)代碼,需要的朋友可以參考下。2010-11-11vbs,hta中選擇文件夾對話框?qū)崿F(xiàn)代碼
在vbs中選擇文件夾可以直接調(diào)用系統(tǒng)的文件夾對話框2009-08-08