Gang's Tech Stuff

DOS Command to display time without prompting for New time

Posted on: February 20, 2009

I think most of us know the DOS command “time/T” which displays current system time without prompting for new time.

But If one needs more granular output, say in HH:MM:SS format, here is a way out, use “echo %TIME%” which expands to current time using same format as TIME command.

There are so many other things which can be echoed. For example, try any of the following variables:

%CD% – expands to the current directory string.

%DATE% – expands to current date using same format as DATE command.

%RANDOM% – expands to a random decimal number between 0 and 32767.

%ERRORLEVEL% – expands to the current ERRORLEVEL value

%CMDEXTVERSION% – expands to the current Command Processor Extensions version number.

%CMDCMDLINE% – expands to the original command line that invoked the Command Processor.

%PATH% – expands the current PATH variable.

etc….

6 Responses to "DOS Command to display time without prompting for New time"

Nicely explained…

thankyou šŸ™‚

I’ve been looking all over for this, thanks

Can you tell me a way by which I can store current time in a text file(file.txt) & then execute a command exactly in one hour(or any specified time)?
.
I figured out redirecting like this works:
echo %time%>File.txt
.
Now how can I create a file(file2.txt) that stores the time exactly one hour after this time(file.txt). Then how can I use both files and compare the current time with the value stored inside file2.txt so that when the value matches or surpasses, any specified command that I want.
.
basic description of the problem:
I want to create a file that logs the time when the computer logs on, then gives exactly 1 hour of usage time, at the end of this period it should display a message “Your computer is about to shut off, please save all required data”. Then it should log off for the rest of the day. If any attempt of logging again is made, it should be denied. Can u help me?

Leave a reply to anon-san Cancel reply


  • Rami Reddy: check whether are you dissable windows firewall or not, if enables windows firewall then you have to dissable then you can access clearcase
  • Henri Hein: Nice tip!
  • Lance Elot: Can you tell me a way by which I can store current time in a text file(file.txt) & then execute a command exactly in one hour(or any specified tim

Categories