Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I want to add some lines to the end of my autoexec.bat file so the date and time are displayed. I want it to look like...
"Today is August 19, 2002."
(skip line)
"The time is 08:40." (or "The time is 8:40AM" if possible to do 12-hour format)Anyone know the commands to do this?

This line will do it (yes, it's all a single line):
echo.EXIT|%COMSPEC%/K PROMPT Today is $D$_ $_The time is $T$_|FIND " "
I just think the format could be a little different from that you want.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

Thanks! You're awesome. It works great. One more question: How do I put a line break before the first line so there is a space between my mouse driver being loaded and "Today is..."
Right now it is running together like this:
Mouse Driver loaded.
Today is Aug 19 2002.And I'm wanting a space between the two lines.
Mouse Driver loaded.
Today is Aug 19 2002.
Also, how do I run "Today is..." and "The Time is.." without a space inbetween?
Today is...
The Time is....Thanks again! It's so neat being able to finally do this. So I'm easily pleased :). But when I see those lines it reminds me of my Amiga 500 days.

You're welcome. To get an additional line, add a "echo." before that line (in a new line) or replace the line by the following:
echo.EXIT|%COMSPEC%/K PROMPT $_ $_Today is $D$_ $_The time is $T$_|FIND " "
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

And how do I make it so there is no space between the line with the date and the line with the time?
Also, I am very much interested in knowing how to do this kind of stuff with DOS and to be able to write batch files and stuff. Any suggestions as to where I should start learning?

In that code line, $_ means a line break, $D means the date and $T means the time. Type "PROMPT /?" for more information.
echo.EXIT|%COMSPEC%/K PROMPT $_ $_Today is $D and the time is $T$_|FIND " "
That line of code is a little bit complex, I don't think I would understand it on the begginning. If you want to play around, try taking out the "|FIND " "" part.
Try this page of links:
http://users.accesscomm.ca/gbraun/batch/batlinks.htmIf you have any question related to batch files, just post them here and some nice people (like me) will certainly be glad to help.
-- Leonardo Pignataro - Secret_Doom --
secret_doom@hotmail.com
www.batch.hpg.com.br

This is my prompt:
Type (E)xit to Return to Windows • DATE: $d • TIME: $t$h$h$h$_PATH: $p $g
If your'e not accessing DOS thru Windows, my other prompt (replacing "Type (E)xit to Return to Windows" [I use Doskey, and have a Doskey macro so e=exit] is "You are in DOS"
This works for me. Maybe it'll work for you.

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |