大家一定要在机器空闲时测试哦。不然真会关掉你的机器的。
'****************************************'*by mengfeiyang'*关机'****************************************Set colOperatingSystems = GetObject("winmgmts:{(Shutdown)}").ExecQuery("Select * from Win32_OperatingSystem")Function shut()setTime=InputBox("请输入多少时间后关机(单位:秒)"," 定时关机", "", 100, 100)If setTime<>"" ThenIF IsNumeric(setTime) ThentimeS=setTime*1000wscript.sleep timeSFor Each objOperatingSystem in colOperatingSystems ObjOperatingSystem.Win32Shutdown(1)NextElse wscript.echo "输入错误,请重试"shut()End IfElse wscript.echo "操作取消"End IfEnd functionshut()