自己写的一个定时关机或重启的vbs脚本
程序员文章站
2022-07-04 20:39:28
dim actionid actionid = 1 '0注销,1关机,2重启, actionti...
dim actionid
actionid = 1 '0注销,1关机,2重启,
actiontime = "2006-1-4 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.sleep(50)
objshell.sendkeys("{up}")
next
for upi = 1 to actionid
wscript.sleep(50)
objshell.sendkeys("{down}")
next
'使用时,请把下行的注释符去掉
'objshell.sendkeys("{enter}")
end function
while true
if datediff("s", now, actiontime) < 0 then
shutdown()
end if
wscript.sleep(5*1000)
wend
'将上面代码存为vbs文件,如:shutdown.vbs,然后双击或在文件上点右键选择以命令提示打开,
'如果到了你设置重启的时候,系统会出现关机的对话框。
'直接下面代码程序会出现关机的对话框,最后的回车注释掉了,正常使用时,请去掉注释符。