Using batch processing to realize computer automatic shutdown _dos/bat

Source: Internet
Author: User
Tags goto
Although you've learned some Windows commands, however, using batch processing to interact with the user and implement an automatic shutdown may not have been tried. Do a shutdown program, it feels different. Let's use Windows batch script to implement automatic shutdown function, the program is not complicated, function can be a lot of Oh! This program is tested in Windows XP/2000/2003 environment.
First step:
Open Notepad and enter the following text (the statement that begins with REM is a comment that you do not have to enter).
Copy Code code as follows:

@echo off
Title Automatic shutdown procedure Author: Green Sword
REM, change it to your name.
Color 17
REM If you don't like the command line default black-white white mode, you can change it with the color command, above "17" to represent the blue background white.
: Start
Echo.
Echo.
Echo Select the action you want to make, and then press ENTER:
Echo.
Echo 1. Timed shutdown
Echo 2. Countdown shutdown
Echo 3. To delete a scheduled shutdown task
Echo 4. To view the status of a scheduled shutdown task
Echo 5. Cancellation
Echo 6. Exit
Echo.
: Set
SET a=
set/p a= Selection:
REM Set Variable "a" for user-entered characters
IF not '%a% ' = = ' SET a=%a:~0,1%
ECHO.
if/i '%a% ' = = ' 1 ' goto 1
if/i '%a% ' = = ' 2 ' Goto 2
if/i '%a% ' = = ' 3 ' Goto 3
if/i '%a% ' = = ' 4 ' Goto 4
if/i '%a% ' = = ' 5 ' goto 5
if/i '%a% ' = = ' 6 ' goto 6
REM If the character entered is not 1-6, it returns a re-enter
The echo%a% selection is invalid, 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
REM If the input is correct, execute: OK after the statement
Echo%shutdowntime% is not a standard time format, please re-enter
Echo.
Goto 1
: OK
Echo.
echo Set, complete! Press any key to continue ...
Pause >nul
Cls
Goto Start
: 2
echo How many seconds do you want to turn off the machine
Echo (if you want to cancel after setting, click "OK" and press CTRL + C key two times)
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 timed Shutdown task canceled, 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 Two:
When you have finished entering, save the file, and in the Save dialog box, select Save type as all files, and the file name is "Automatic shutdown program. bat".
Step Three:
See this program suffix name is bat, and the icon is also very soil, do not worry, we can use WinRAR3.0 above version of this batch file into an EXE file, the following methods:
If your system is not installed winrar please install first
Select "Automatic shutdown program. bat" and select "Add to Profile (A)" In the right-click menu.
Select Create Self release format profile in compression options
Click the Advanced tab, click SFX Options, and open the Advanced Self release options on the General tab, in the "Run after release", enter the compressed file name "Auto Shutdown program. bat"
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 Icons tab. In the Custom SFX file icon, enter or browse the path of your favorite icon in the text box under SFX icon from file. If you do not have the icon, you can open the system on the disk, use the search, in the search file name to enter " *.ico "can find a lot of icons, the Find the icon path and filename input text box can be.
After the confirmation, that is, in the original folder more than an "automatic shutdown program." File, the result has now been caused!
Related Article

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.