星期三, 八月 11, 2010

VBS off network shutdown automatically after 30 seconds

Just run it after the cable is pulled out once, then automatically shut down immediately into the countdown, "-t 30" is the countdown of the time, you can make their own adjustments.

Code:

Dim Wsh, objWMIService, colMonitoredEvents
Set Wsh = WScript.CreateObject ("WScript.Shell")
Set objWMIService = GetObject ("winmgmts: \. Ootwmi")
Set colMonitoredEvents = objWMIService.ExecNotificationQuery ("Select * from MSNdis_StatusMediaDisconnect")
Do While True
Set strLatestEvent = colMonitoredEvents.NextEvent
Wsh.run "shutdown-s-t 30-c" & chr (34) & "Network disconnected, the machine will close" & chr (34)
Loop

没有评论:

发表评论