只要运行它后,一旦网线被拔掉的话,马上就进入自动关机倒计时,“-t 30”是倒计时的时间,你可以自己调整。
代码如下:
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)&"系统网络断开,机器即将关闭"&chr(34)
Loop
2025国考·省考课程试听报名