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 batch processing to realize automatic computer shutdown

2025-01-19 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 batch processing to achieve automatic computer shutdown, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

Although you have learned some Windows commands, using batch processing to interact with users and achieve automatic shutdown may not have been tried. It feels different to make a shutdown program by yourself. Below we use Windows batch script, to achieve automatic shutdown function, the program is not complex, the function can be a lot of oh! This procedure passed the test under the Windows xp/2000/2003 environment.

Step one:

Open notepad and enter the following text (statements that begin with rem are comments, so you don't have to type them).

The code is as follows:

@ echo off

Title automatic shutdown program author: Qingjian

Rem, change it to your name here.

Color 17

Rem if you don't like the default black-and-white mode on the command line, you can change it with the color command, where "17" stands for white on a blue background.

: start

Echo.

Echo.

Echo, please select the action you want to perform, and then press enter:

Echo.

Echo 1. Timing shutdown

Echo 2. Countdown to shutdown

Echo 3. Delete scheduled shutdown task

Echo 4. Check the status of scheduled shutdown tasks

Echo 5. Write off

Echo 6. Quit

Echo.

: set

SET a =

SET / P a = Select:

Rem sets the variable "a" as the character entered by the user

IF NOT'% a% thank you 'SET asides% aVub 1%

ECHO.

IF / I'% a% goto 1

IF / I'% a% goto 2

IF / I'% a% goto 3

IF / I'% a% thank you. 4 'goto 4

IF / I'% a% thank you. 5' goto 5

IF / I'% a% goto 6

Rem if the character entered is not 1-6, it will be returned to re-enter

Echo a% selection is not valid, please re-enter:

Echo.

Goto set

: 1

Echo, please enter the shutdown time (e.g. 12:00:00)

Set shutdowntime=

Set / p shutdowntime=

At shutdowntime% tsshutdn 0 / delay:0 / powerdown > nul

IF not errorlevel 1 goto ok

If rem is entered correctly, execute the following statement: ok

Echo shutdowntime% is not a standard time format, please re-enter it

Echo.

Goto 1

: ok

Echo.

Echo is set! Press any key to continue.

Pause > nul

Cls

Goto start

: 2

Echo, how many seconds do you want to turn off your phone?

Echo (if you want to cancel after setting, click OK and press Ctrl+C twice)

Set timed=

Set / p timed= input:

Tsshutdn timed% / delay:0 / powerdown > nul

IF not errorlevel 1 goto ok

Echo timed% is an invalid shutdown time, please re-enter

Echo.

Goto 2

: 3

At / del / y

Echo scheduled shutdown task has been cancelled, press any key to continue.

Pause > nul

Cls

Goto start

: 4

At

Echo press any key to continue.

Pause > nul

Cls

Goto start

: 5

Logoff

: 6

Exit

Step 2:

After input, save the file, in the Save dialog box, select "Save as type" to "all files", the file name is "automatic shutdown program .bat".

Step 3:

Look at the suffix name of this program is bat, and the icon is also very corny, don't worry, we can use the above version of WinRAR3.0 to make this batch file into an exe file, the method is as follows:

If your system does not have WinRAR installed, please install it first.

Select "Auto shutdown Program .bat" and select "add to Archive (A)" from the right-click menu. "

In Compression options, select create self-release format Archive

Click the "Advanced" tab, click "SFX options", open "Advanced self-release options" and enter the compressed file name "automatic shutdown Program .bat" in "run after release" in the "General" tab.

Click the "Mode" tab, select "unpack to temporary folder", select "hide all" in silent mode, and select "overwrite all files" in "overwrite mode".

If you want to change the default icon, you can open the "text and Icon" tab and enter or browse the path of your favorite icon in the text box under "load SFX Icon from File" in "Custom SFX File Icon". If you do not prepare the icon, you can open the system disk, use the search, type "* .ico" in the search file name to find many icons, and enter the icon path and file name into the text box.

After being determined in turn, there is a file of "automatic shutdown program .exe" in the original folder, and great work has been done now!

Thank you for reading this article carefully. I hope the article "how to use batch processing to realize automatic computer shutdown" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support and pay attention to 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