你們必定要在機器空閒時測試哦。否則真會關掉你的機器的。測試
'**************************************** '*by mengfeiyang '*關機 '**************************************** Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem") Function shut() setTime=InputBox("請輸入多少時間後關機(單位:秒)"," 定時關機", "", 100, 100) If setTime<>"" Then IF IsNumeric(setTime) Then timeS=setTime*1000 wscript.sleep timeS For Each objOperatingSystem in colOperatingSystems ObjOperatingSystem.Win32Shutdown(1) Next Else wscript.echo "輸入錯誤,請重試" shut() End If Else wscript.echo "操做取消" End If End function shut()