Microsoft KB Archive/68049

Batch File to Put Current Date/Time into Environment Variables PSS ID Number: Q68049 Article last modified on 02-05-1993 PSS database name: O_MSDOS

3.20 3.21 3.30 3.30a 4.00 4.01 4.01a

MS-DOS

Summary:

The following batch file, TODAY.BAT, can be used to put the current date and time into environment variables called DATE and TIME.

Note: This batch file is designed to have the TODAY.BAT file located in the C: directory. The MS-DOS file FIND.EXE must be located in the path, and you must be able to write to the current drive. Also, make note that “TODAY” in quotation marks must be capitalized or FIND.EXE will not be able to find it.

TODAY.BAT
ECHO OFF CLS IF NOT %4.==. GOTO label COPY /B C:.BAT+,, > NUL DIR C:.BAT | FIND “TODAY” > TEMP.BAT TEMP.BAT :label SET date=%3 SET time=%4 DEL TEMP.BAT

Additional reference words: 3.2 3.20 3.3 3.30 3.3a 3.30a 4.0 4.00 4.01 4.01a noupd

Copyright Microsoft Corporation 1993.