Computing.Net > Forums > Disk Operating System > How to display time and date in autoexec

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

How to display time and date in autoexec

Reply to Message Icon

Name: philowar
Date: August 19, 2002 at 08:38:32 Pacific
Comment:

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?



Sponsored Link
Ads by Google

Response Number 1
Name: Secret_Doom
Date: August 19, 2002 at 10:51:02 Pacific
Reply:

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


0

Response Number 2
Name: philowar
Date: August 19, 2002 at 12:18:39 Pacific
Reply:

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.


0

Response Number 3
Name: Secret_Doom
Date: August 19, 2002 at 12:50:54 Pacific
Reply:

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


0

Response Number 4
Name: philowar
Date: August 19, 2002 at 14:26:16 Pacific
Reply:

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?


0

Response Number 5
Name: Secret_Doom
Date: August 19, 2002 at 18:27:00 Pacific
Reply:

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.htm

If 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


0

Related Posts

See More



Response Number 6
Name: Renaissance Man
Date: August 20, 2002 at 07:20:15 Pacific
Reply:

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.


0

Sponsored Link
Ads by Google
Reply to Message Icon






Post Locked

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


Go to Disk Operating System Forum Home


Sponsored links

Ads by Google


Results for: How to display time and date in autoexec

How to create a log file in 1 line www.computing.net/answers/dos/how-to-create-a-log-file-in-1-line/12735.html

Date output to variable. Scheduler www.computing.net/answers/dos/date-output-to-variable-scheduler/15566.html

how to copy files using date www.computing.net/answers/dos/how-to-copy-files-using-date/12582.html