Automatic shutdown using batch processing

Source: Internet
Author: User

Although you have learned some Windows commands, you may not have tried using batch processing to interact with users and implement automatic shutdown. make a Shutdown program by yourself and feel different. next we will use the Windows batch processing script to implement the automatic shutdown function. The program is not complicated, and there are a lot of functions! This program passes the test in Windows xp/2000/2003.
Step 1:
Open notepad and enter the following text (the statement starting with rem is a comment, you do not need to enter it ). Copy codeThe Code is as follows: @ echo off
Title automatic shutdown program Author: qingjian
Rem, change it to your name.
Color 17
Rem if you do not like the default black-white mode of the command line, you can use the color command to change it. The above "17" indicates the blue-white text.
: Start
Echo.
Echo.
Select the operation to be performed for echo, and press Enter:
Echo.
Echo 1. Timed Shutdown
Echo 2. Countdown Shutdown
Echo 3. Delete the Timed Shutdown task
Echo 4. view the Timed Shutdown task status
Echo 5. logout
Echo 6. Exit
Echo.
: Set
SET a =
SET/P a = select:
The rem setting variable "a" is a character entered by the user
If not '% a %' = ''SET 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 entered character is not 1-6, it will return re-Input
Echo % a % The selection is invalid. Please enter it again:
Echo.
Goto set
: 1
Input the shutdown time for echo (for example, 12:00:00)
Set shutdowntime =
Set/p shutdowntime =
At % shutdowntime % tsshutdn 0/delay: 0/powerdown> nul
IF not errorlevel 1 goto OK
If the input is correct, run the statement after OK.
Echo % shutdowntime % is not the standard time format. Please try again
Echo.
Goto 1
: OK
Echo.
Echo settings complete! Press any key to continue...
Pause> nul
Cls
Goto start
: 2
Echo how many seconds do you want to shut down
Echo (if you want to cancel 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 % indicates the shutdown time is invalid. Please enter a new one.
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 2:
After entering the information, save the file. In the "save" dialog box, set "Save type" to "all files" and the file name to "automatically shut down program. bat.
Step 3:
Check that the extension name of this program is bat, and the icon is also very earthy. Don't worry, we can use WinRAR3.0 or a later version to make this batch file into an exe file. The method is as follows:
If WinRAR is not installed on your system, install it first.
Select "automatic shutdown program. bat", right-click the menu, and select "add to file ()... "
In "compression options", select "Create a self-released file"
Click the "advanced" tab and click "SFX Options" to open "advanced auto release options". On the "General" tab, click "Release and run" Enter compressed file name "to automatically shut down the program. bat"
Click the "Mode" tab, select "unpack to Temporary Folder", select "hide all" in "Silence mode", and select "overwrite all files" in "override mode"
If you want to change the default icon, you can open the "text and icon" label, in the text box under "load SFX from file" of "Custom SFX file icon", enter or browse the path of your favorite icon. if you do not have the preparation icon, you can open the disk where the system is located, use search, and enter "*. ico, you can find a lot of icons, and enter the icon path and file name in the text box.
After confirming the order, a file named "automatically shut down program .exe" is added to the original folder. This is now a big task!

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.