How I can get the system uptime in milliseconds from the Windows command line? I want something like the result of this function: gettickcount(), e.g. 24233241231.

Is there a command, utility or trick for this?

  • 9
    What operating system is this for? – Dave Mar 13 '13 at 11:33
  • 1
    @MarcksThomas I don't see the problem here, there is nothing wrong with adding requirements afterwards, being the OP... – BloodPhilia Mar 13 '13 at 22:50
  • 1
    It is not up to other users to change the nature of the question so radically as to no longer reflect the OP's problem. What more users started posting Linux solutions? That wouldn't help the OP at all. – BloodPhilia Mar 13 '13 at 22:58
  • @H.-DirkSchmitt Except this isn't a restaurant, it's a place where people come for help. If you're just in it for the reputation, I feel you're in it for all the wrong reasons. I haven't flagged your answer for deletion of whatever. And although it's true that a non-OP user edited the question, he has done so to reflect the wishes and requirements of the OP. If you want to debate this, feel free to join me in chat. – BloodPhilia Mar 13 '13 at 23:02
  • 1
    @H.-DirkSchmitt: Frankly, I think the answer has merit, at least until we reach a consensus on meta. – Marcks Thomas Mar 13 '13 at 23:31

You`re sure that you want the milliseconds via command line utility. IMHO the overhead starting a new process to fetch this will take a little bit to long.

If seconds also fits your requirements, here is a little outline to get with some bash code.
The further assumption is that you have some kind of unix. This example works on a current linux system.

# Reading the time of boot
bootTime=$(awk '/^btime/{print $2;}' </proc/stat)
currentTime=$(date +%s)
liveTime=$(( ${currentTime} - ${bootTime} ))
echo "online since: ${liveTime}"
  • what about Windows? – ayyob khademi Mar 13 '13 at 18:31
  • 1
    @ayyobkhademi: Parsing this line is a huge pain from the Windows command line, but you could use this as a source: systeminfo /FO list | findstr /C:"System Boot Time:". – Marcks Thomas Mar 13 '13 at 21:25

For windows, execute the following text in command line: net stats srv


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.