Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use vbs to implement a script that shuts down or restarts regularly

2025-01-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly introduces how to use vbs to achieve a timing shutdown or restart script, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let Xiaobian take you to understand.

Dim ActionID

ActionID = 1'0 logout, 1 shutdown, 2 restart

ActionTime = "2006-1-4 13:42:30" 'shutdown or restart time

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

'Please remove the comments on the following line when using it

'objShell.sendKeys ("{ENTER}")

End function

While true

If DateDiff ("s", Now, ActionTime) < 0 then

ShutDown ()

End if

WScript.Sleep (5x 1000)

Wend

'Save the above code as a vbs file, such as shutdown.vbs, and then double-click or right-click on the file to open it at the command prompt

If it's time for you to set up a restart, the system will display a shutdown dialog box.

'directly below the code program will appear the shutdown dialog box, and the final enter comment has been dropped. When in normal use, please remove the comment character.

Thank you for reading this article carefully. I hope the article "how to use vbs to achieve a scheduled shutdown or restart script" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and follow the industry information channel. More related knowledge is waiting for you to learn!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report