In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-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 batch processing to achieve automatic shutdown of the system, which has a certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article.
@ ECHO off
TITLE automatic shutdown program author: Liao Xiaoqing
: start
CLS
COLOR 1f
Rem uses the COLOR command to change the console output color
MODE con: COLS=41 LINES=18
The rem MODE statement sets the width and height of the form
Set tm1=%time:~0,2%
Set tm2=%time:~3,2%
Set tm3=%time:~6,2%
ECHO date% tm1% points tm2% minutes tm3% seconds
ECHO = =
ECHO, please select the operation you want to perform, and then press enter
ECHO ─
ECHO.
ECHO 1. Timing shutdown
ECHO 2. Countdown to shutdown
ECHO 3. Delete scheduled shutdown task
ECHO 4. View task status
ECHO 5. Refresh the current time
ECHO 6. Restart
ECHO 7. Lock the computer
ECHO 8. Write off
ECHO 9. Quit
ECHO.
: cho
SET Choice=
SET / P Choice= selection:
Rem sets the variable "Choice" as the character entered by the user
IF NOT "% Choice%" = "" SET Choice=%Choice:~0,1%
Rem if the input is greater than 1 bit, take the first bit, for example, enter 132, then the return value is 1
ECHO.
IF / I "% Choice%" = = "1" GOTO SetHour
IF / I "% Choice%" = = "2" GOTO outtime
IF / I "% Choice%" = = "3" GOTO delAt
IF / I "% Choice%" = = "4" GOTO view
IF / I "% Choice%" = = "5" GOTO start
IF / I "% Choice%" = = "6" GOTO restart
IF / I "% Choice%" = = "7" GOTO lock
IF / I "% Choice%" = = "8" GOTO logoff
IF / I "% Choice%" = = "9" GOTO end
In order to avoid program exceptions caused by empty return values or spaces in rem, it is necessary to put double quotation marks around the variables.
Rem note that the IF statement requires a double equals sign
Rem if the character entered is not the above number, it will be returned to re-enter
Invalid ECHO selection, please re-enter
ECHO.
GOTO cho
: SetHour
CLS
ECHO.
SET ask=
Whether SET / p ask= is set to execute the shutdown command every day (yzone):
IF NOT "% ask%" = "" SET ask=%ask:~0,1%
IF / I "% ask%" = = "y" GOTO yes
IF / I "% ask%" = = "n" GOTO no
GOTO SetHour
: yes
For ECHO, please specify a 24-hour standard time in hours: minutes.
SET shutdowntime=
SET / p shutdowntime= input:
At shutdowntime% / every:M,T,W,Th,F,S,Su tsshutdn 0 / delay:0 / powerdown > nul
Rem is set every week from Monday to Sunday, that is, every day
IF NOT errorlevel 1 GOTO ok
Rem executes the statement of the ok section if it is entered correctly
ECHO shutdowntime% is not a standard time format, please re-enter it
ECHO.
GOTO yes
: no
For ECHO, please specify a 24-hour standard time in hours: minutes.
SET shutdowntime=
SET / p shutdowntime= input:
At shutdowntime% tsshutdn 0 / delay:0 / powerdown > nul
IF NOT errorlevel 1 GOTO ok
ECHO shutdowntime% is not a standard time format, please re-enter it
ECHO.
GOTO no
: ok
ECHO.
SET hobbies% shutdowntimelug 1%
SET ah=%shutdowntime:~0,1%
SET am=%shutdowntime:~2,2%
SET bh=%shutdowntime:~0,2%
SET bm=%shutdowntime:~3,2%
IF "% h%" = ":" (
% am% points at SET HM=%ah%
) ELSE (
% bm% points at SET HM=%bh%)
Rem if you enter h:mm, then mm points for HM=h, otherwise mm points for HM=hh
IF / I "% ask%" = "y" ECHO system will be shut down at% HM% every day
IF / I "% ask%" = "n" ECHO system will be shut down at% HM%
ECHO is set! Press any key to continue.
PAUSE > nul
GOTO start
: outtime
CLS
ECHO.
ECHO, please enter the countdown seconds
ECHO ─
ECHO (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 outtime
: delAt
Cls
Echo.
At / del / y
Echo scheduled shutdown task has been cancelled, press any key to continue.
Pause > nul
GOTO start
: view
MODE con: COLS=85 LINES=18
COLOR 70
ECHO.
At
ECHO press any key to continue.
PAUSE > nul
GOTO start
: restart
Shutdown-r-t 0
: lock
Rundll32.exe user32.dll,LockWorkStation
Goto start
: logoff
Logoff
: end
Exit
Thank you for reading this article carefully. I hope the article "how to use batch processing to realize automatic 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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.