关机合集--bat/vbs格式

关机代码如下;

bat格式

滑动关机;

slidetoshutdown

定时关机;

shutdown -s -t 360
//现在让系统360秒之后关机

shutdown -a
//终止关闭计算机

直接关机;

shutdown -s -t 1

vbs格式;

定时关机;

shutdown -s -t 1

定时关机复杂;

timestr = InputBox("请输入延时时间(小时)","关机时间")
 if(timestr<>"") then
     shutdownbut = msgbox("是否确定在"+timestr+"个小时后关机",vbOKCancel,"提示")
     if shutdownbut=vbOK then
         tm = (0)
         'tm = (timestr*3600)  
         msgbox "系统将在"+timestr+"小时后关机",vbOKOnly+VbExclamation,"提示"
         CreateObject("Wscript.Shell").run "cmd.exe /c shutdown -s -t "&cstr(tm)
     else
         msgbox "取消了关机",vbOKOnly+vbinformation,"提示"
     end if
 end if
————————————————
版权声明:本文为CSDN博主「枣树下的石磙」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/w757227129/article/details/78101420

上面代码引用了博主【枣树下的石磙】所编制的代码

定时关机3;

Dim value
value=inputbox("0:取消关机" & Chr(10) & "1:关机1小时"& Chr(10) & "2:关机2小时"& Chr(10) & "3:关机3小时","轩阁工具箱","",9000,5000)
If value = 1 Then 
    dim WSHshellA
    set WSHshellA=wscript.createobject("wscript.shell")
    WSHshellA.run"cmd.exe /c shutdown -a",0,true
    WSHshellA.run"cmd.exe /c shutdown -s -t 3600 -f",0,true
    Msgbox "计算机将在1小时后关机!"
ElseIf value = 0 Then 
    dim WSHshellO
    set WSHshellO=wscript.createobject("wscript.shell")
    WSHshellO.run"cmd.exe /c shutdown -a",0,true
    Msgbox "取消关机!"
ElseIf value = 2 Then
    dim WSHshellB
    set WSHshellB=wscript.createobject("wscript.shell")
    WSHshellB.run"cmd.exe /c shutdown -a",0,true
    WSHshellB.run"cmd.exe /c shutdown -s -t 7200 -f",0,true
    Msgbox "计算机将在2小时后关机!"
ElseIf value = 3 then
    dim WSHshellC
    set WSHshellC=wscript.createobject("wscript.shell")
    WSHshellC.run"cmd.exe /c shutdown -a",0,true
    WSHshellC.run"cmd.exe /c shutdown -s -t 10800 -f",0,true
    Msgbox "计算机将在3小时后关机!"
ElseIf value =""  then
    dim WSHshellD
    set WSHshellD=wscript.createobject("wscript.shell")
    WSHshellD.run"cmd.exe /c shutdown -a",0,true
Else
    dim WSHshellZ
    Msgbox "输入错误,请重新输入!"
End if

 此代码引用了博主【旧梦澜轩】的代码

https://blog.csdn.net/weixin_42404697/article/details/95191228 

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Ave·

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值