只要運(yùn)行它后,一旦網(wǎng)線被拔掉的話,馬上就進(jìn)入自動(dòng)關(guān)機(jī)倒計(jì)時(shí),“-t 30”是倒計(jì)時(shí)的時(shí)間,你可以自己調(diào)整。
代碼如下:
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)&"系統(tǒng)網(wǎng)絡(luò)斷開(kāi),機(jī)器即將關(guān)閉"&chr(34)
Loop