@echo off :: "JustTime.bat" puts the current time into the environment :: Written under MSDOS 7 (Win95), should work on all recent versions. :: The trick here is to use the first word of a command output :: as the name of a batch file. :: First find the line starting with "Current" that ends with the time :: A single CR/LF is sent to TIME with ECHO. to end the TIME command echo.|time|find /i "current" >cu##ent.bat :: We now have "Current time is 1:45:59.82p" (without quotes) in CU##ENT.BAT :: Since the first word is CURRENT, we need a command with that name ready :: Now create a batch file named CURRENT.BAT :: CURRENT.BAT will set the TIME variable to it's third argument (the time) echo set time=%%3>current.bat :: We now have "set time=%3" (without the quotes) in CURRENT.BAT :: Now CALL our CU##ENT.BAT, which will in turn run CURRENT.BAT call cu##ent.bat :: Display the time we worked so hard to get echo %TIME% :: Now delete both temporary batch files and erase the TIME variable del cu??ent.bat > nul set time= :: http://www.ericphelps.com