这篇文章主要讲解了“vbs怎么实现的定时关机或重启”,文中的讲解内容简单清晰,易于学习与理解,下面请大家跟着小编的思路慢慢深入,一起来研究和学习“vbs怎么实现的定时关机或重启”吧!
代码如下:
'定时关机或重启的脚本,在windows 2000下通过
' code by haiwa 2005-11-7 dim ActionID ActionID = 1 '0注销,1关机,2重启, ActionTime = "2005-11-7 13:42:30" '关机或重启时间 function ShutDown) dim objShell Set objShell = WScript.CreateObject"Wscript.Shell") dim Application set Application = CreateObject"Shell.Application.1") Application.ShutdownWindows) dim upi for upi = 0 to 4 WScript.Sleep50) objShell.sendKeys"{UP}") next For upi = 1 to ActionID WScript.Sleep50) objShell.sendKeys"{DOWN}") next '使用时,请把下行的注释符去掉 'objShell.sendKeys"{ENTER}") end function While true if DateDiff"s", Now, ActionTime) < 0 then ShutDown) end if WScript.Sleep5*1000) wend