How VBS monitors network connections and disconnections
Editor to share with you how VBS monitors network connections and disconnections, I believe most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's learn about it!
Monitor network connections:
The copy code is as follows:
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
The monitoring network is down:
The copy code is as follows:
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
The above is all the contents of the article "how VBS monitors network connections and disconnections". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!