Use the doscommand to create a desktop dynamic clock

Source: Internet
Author: User

I often see a dynamic digital clock on the sidebar of someone else's computer desktop. Today, with an whimsy, I tried to use the doscommand.
Open notepad and enter the following content.
@ Echo off
Title dynamic clock
Color 1f
Mode con Cols = 20 lines = 8
Echo.
Echo's current time is
Echo.
Echo % date %
Echo % time :~ 0,-3%.
Ping-N 2 127.1> NUL
CLS
% 0
Save it as clock. bat. Double-click to run it.

This program may not be very practical, mainly in the hope that computer beginners can learn a few DOS commands. Now I will explain the meaning of the key part of the code.
Color is used to define the foreground color and background color.
The next line defines the height and width of the dialog box.
Echo % date % is used to display the date of the current day.
Echo % time :~ 0,-3% is used to display the time of the day, but the syntax of this sentence is different from the previous sentence, this is because the number of milliseconds is displayed by default, and we do not need. Therefore
"-3" removes the last three digits. That is, remove the last colon and two milliseconds. ":~ 0 indicates that the number of digits in the front is not equal. The entire sentence indicates that the previous time is retained, and only the colon and the number of milliseconds are removed.
Next we use Ping-N 2 127.1> NUL to delay one second. (Actually more than one second, less than two seconds)
Run itself with % 0. This achieves the purpose of dynamic clock.

 

Http://www.cfanclub.net/article.php? Itemid-38692-type-news.html

 

 

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.