Batch Processing enables Timed Shutdown, logout, restart, lock, and other functions

Source: Internet
Author: User
Tags echo 7

Copy codeThe Code is as follows: @ ECHO off
TITLE greaterthanme-enables Timed Shutdown, logout, restart, and lock. 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 % point % tm2 % minute % tm3 % second
ECHO ===================================================== =
Select the operation to be performed for ECHO, and press ENTER
ECHO ---------------
ECHO.
ECHO 1. Timed Shutdown
ECHO 2. Countdown Shutdown
ECHO 3. Delete the Timed Shutdown task
ECHO 4. View task status
ECHO 5. Refresh the current time
ECHO 6. Restart
ECHO 7. Lock the computer
ECHO 8. logout
ECHO 9. Exit
ECHO. cho
SET Choice =
Set p Choice = select
Rem sets 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 1st bits. For example, if the input is 132, 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 null or spaces returned, add double quotation marks outside the variable.
Rem Note: The IF statement requires a double equal sign.
Rem if the entered character is not a number above, it will return re-Input
The ECHO selection is invalid. enter a new one.
ECHO.
GOTO choSetHour
CLS
ECHO.
SET ask =
SET p ask = SET to execute the shutdown command every day (yn)
If not % ask % = SET ask = % ask ~ 0, 1%
If I % ask % = y GOTO yes
If I % ask % = n GOTO no
GOTO SetHouryes
Specify the 24-hour Standard Time for ECHO, in the format of hour-minute
SET shutdowntime =
SET p shutdowntime = Input
At % shutdowntime % everyM, T, W, Th, F, S, Su tsshutdn 0 delay0 powerdown nul
Rem is set to Monday to Sunday, that is, every day.
If not errorlevel 1 GOTO OK
If the input is correct, run the Statement of the OK segment.
ECHO % shutdowntime % is not the standard time format. Please try again
ECHO.
GOTO yesno
Specify the 24-hour Standard Time for ECHO, in the format of hour-minute
SET shutdowntime =
SET p shutdowntime = Input
At % shutdowntime % tsshutdn 0 delay0 powerdown nul
If not errorlevel 1 GOTO OK
ECHO % shutdowntime % is not the standard time format. Please try again
ECHO.
GOTO nook
ECHO.
SET h = % shutdowntime ~ 1, 1%
SET ah = % shutdowntime ~ 0, 1%
SET am = % shutdowntime ~ 2,2%
SET bh = % shutdowntime ~ 0, 2%
SET bm = % shutdowntime ~ 3,2%
IF % h % = (
Set hm = % ah % hour % am % minute
) ELSE (
Set hm = % bh % bm % points)
Rem if hmm is input, HM = h mm, otherwise HM = hh mm
If I % ask % = y ECHO system will close % HM % every day
If I % ask % = n ECHO system will be disabled at % HM %
ECHO settings complete! Press any key to continue...
PAUSE nul
GOTO startouttime
CLS
ECHO.
Please input countdown seconds for ECHO
ECHO --------
ECHO (to cancel setting, click OK and press Ctrl + C twice)
SET timed =
SET p timed = Input
Tsshutdn % timed % delay0 powerdown nul
IF not errorlevel 1 GOTO OK
ECHO % timed % indicates the shutdown time is invalid. Please enter a new one.
ECHO.
GOTO outtimedelAt
Cls
Echo.
At del y
Echo Timed Shutdown task canceled. Press any key to continue...
Pause nul
GOTO startview
MODE con COLS = 85 LINES = 18
COLOR 70
ECHO.
At
ECHO press any key to continue...
PAUSE nul
GOTO startrestart
Shutdown-r-t 0 lock
Rundll32.exe user32.dll, LockWorkStation
Goto startlogoff
Logoffend
Exit

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.