关机代码如下;
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