定时关机VBS脚本-自动关机代码Dim mytime,myout1,myout2 mytime=null mytime=InputBox(请输入定时时间(格式20:10:05)&vblf&如果想倒计时...

谷子猫博客

一个简单爱分享的小站!^_^!
首页>> 技术文档 >>定时关机VBS脚本
2009-11-12
分类: 技术文档

定时关机VBS脚本

文章作者:谷子猫
手机扫码查看

自动关机代码Dim mytime,myout1,myout2 mytime=null mytime=InputBox("请输入定时时间(格式20:10:05)"&vblf&"如果想倒计时关机,请输入倒......

自动关机代码

Dim mytime,myout1,myout2
mytime=null
mytime=InputBox("请输入定时时间(格式20:10:05)"&vblf&"如果想倒计时关机,请输入倒计时时间"&vblf&"(单位/分钟)"&vblf&"输入‘xxx’可以马上关机"&vblf&"退出点‘取消’","定时关机","1")
Set wshshell=wscript.createobject("wscript.shell")
If IsNumeric(mytime)=False Then
If IsDate(mytime)=True Then
wshshell.run "at "&mytime&" shutdown -s" '定时关机在任务列表中
myout1=MsgBox("定时成功!电脑将在"&mytime&"关机!放弃关机请点‘取消’!",vbokcancel,"定时关机")
If myout1=vbcancel Then
wshshell.run "at /delete /y"
MsgBox "关机已取消!",64,"定时关机"
End If
Else
If mytime="xxx" Then
wshshell.run "shutdown -s -t 0"
End If
MsgBox "输入错误!请重新输入!",64,"定时关机"
End If
Else
If mytime>600 or mytime<=0 Then
MsgBox "输入错误!倒计时不能多于10小时(600分钟)!",64,"定时关机"
wscript.quit
End If
wshshell.run "shutdown -s -t "&mytime*60
myout2=MsgBox("设置成功!电脑将在"&mytime&"分钟后关机!放弃关机请点‘取消’!",vbokcancel,"定时关机")
If myout2=vbcancel Then
wshshell.run "shutdown -a"
MsgBox "关机已取消!",64,"定时关机"
End If
End If

存为.vbs
也可以下载直接使用,谢谢物午夜客和hanmiao。
[file][/file]

×

感谢您的支持,我们会一直保持!

扫码支持
请土豪扫码随意打赏

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

打赏作者
版权所有,转载注意明处:谷子博客 » 定时关机VBS脚本
标签: 代码

发表评论

路人甲

网友评论(2)

博主能不能把这个脚本保存为vbs脚本文件然后上传到你的博客中来,这样我们想用它的时候直接下载就行了。
hanmiao 15年前 (2009-11-12) 回复
脚本运行不了!


下面的修改一下!










Dim mytime,myout1,myout2
mytime=null
mytime=InputBox(&quot;请输入定时时间(格式20:10:05)&quot;&amp;vblf&amp;&quot;如果想倒计时关机,请输入倒计时时间&quot;&amp;vblf&amp;&quot;(单位/分钟)&quot;&amp;vblf&amp;&quot;输入‘xxx’可以马上关机&quot;&amp;vblf&amp;&quot;退出点‘取消’&quot;,&quot;定时关机&quot;,&quot;1&quot;)
Set wshshell=wscript.createobject(&quot;wscript.shell&quot;)
If IsNumeric(mytime)=False Then
If IsDate(mytime)=True Then
wshshell.run &quot;at &quot;&amp;mytime&amp;&quot; shutdown -s&quot; 定时关机在任务列表中
myout1=MsgBox(&quot;定时成功!电脑将在&quot;&amp;mytime&amp;&quot;关机!放弃关机请点‘取消’!&quot;,vbokcancel,&quot;定时关机&quot;)
If myout1=vbcancel Then
wshshell.run &quot;at /delete /y&quot;
MsgBox &quot;关机已取消!&quot;,64,&quot;定时关机&quot;
End If
Else
If mytime=&quot;xxx&quot; Then
wshshell.run &quot;shutdown -s -t 0&quot;
End If
MsgBox &quot;输入错误!请重新输入!&quot;,64,&quot;定时关机&quot;
End If
Else
If mytime&gt;600 or mytime&lt;=0 Then
MsgBox &quot;输入错误!倒计时不能多于10小时(600分钟)!&quot;,64,&quot;定时关机&quot;
wscript.quit
End If
wshshell.run &quot;shutdown -s -t &quot;&amp;mytime*60
myout2=MsgBox(&quot;设置成功!电脑将在&quot;&amp;mytime&amp;&quot;分钟后关机!放弃关机请点‘取消’!&quot;,vbokcancel,&quot;定时关机&quot;)
If myout2=vbcancel Then
wshshell.run &quot;shutdown -a&quot;
MsgBox &quot;关机已取消!&quot;,64,&quot;定时关机&quot;
End If
End If
午夜客 15年前 (2009-11-12) 回复