Get the App
SLTechnology News&Howtos  ›  Development  › 

How to write a vbs script that can shut down automatically at a fixed time

Shulou Source: shulou.com Published: 2022-06-03 08:33:35 11月15日 Update

This article mainly explains "how to write a vbs script that can automatically shut down on a regular basis". The explanation in this article is simple and clear, easy to learn and understand. Please follow the ideas of Xiaobian slowly and deeply to study and learn "how to write a vbs script that can automatically shut down on a regular basis" together!

The copy code is as follows:

Dim mytime,myout1,myout2

mytime=null

mytime=InputBox("Please enter timing time (format 20:10:05)"&vblf&"If you want to count down shutdown, please enter countdown time"&vblf&"(unit/min)"&vblf&"Enter 'xxx' to shut down immediately"&vblf&"Exit point 'Cancel'," Timed shutdown ","1")

Set wshshell=wscript.createobject("wscript.shell")

If IsNumeric(mytime)=False Then

If IsDate(mytime)=True Then

wshshell.run "at "&mytime&" shutdown -s" 'timed shutdown in task list

myout1=MsgBox("Timing succeeded! The computer will shut down at "&mytime&"! Please click 'Cancel' to abort shutdown! ",vbokcancel," timed shutdown ")

If myout1=vbcancel Then

wshshell.run "at /delete /y"

MsgBox "Shutdown cancelled! "64." Timed shutdown."

End If

Else

If mytime="xxx" Then

wshshell.run "shutdown -s -t 0"

End If

MsgBox "input error! Please re-enter! "64." Timed shutdown."

End If

Else

If mytime>600 Or mytime=guanji then

diaolei.run "rundll32.exe user.exe,exitwindows"

diaolei.run "shutdown -s -t 0"

elseif hua=2 then

guanji=inputbox("Please enter how many hours you want to shut down")

if datediff("h",shijian,time)>=guanji then

diaolei.run "rundll32.exe user.exe,exitwindows"

diaolei.run "shutdown -s -t 0"

elseif hua=3 then

guanji=inputbox("Please enter how many days you want to shut down")

if datediff("d",shijian,time)>=guanji then

diaolei.run "rundll32.exe user.exe,exitwindows"

diaolei.run "shutdown -s -t 0"

endif

Thank you for reading, the above is "how to write can automatically shut down the timing of the vbs script" content, after learning this article, I believe we can write automatic shutdown of the timing of the vbs script this issue has a deeper understanding, the specific use of the need for everyone to practice verification. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!

Tags: Input script code countdown representative hour learning success content unit time computer error task diva that is ideas situations articles more Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux Huawei Shulou Tech Info Xiaomi MariaDB