2

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?

7
  • 9
    What operating system is this for?
    – Dave
    Commented Mar 13, 2013 at 11:33
  • 1
    @MarcksThomas I don't see the problem here, there is nothing wrong with adding requirements afterwards, being the OP...
    – Pylsa
    Commented Mar 13, 2013 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.
    – Pylsa
    Commented Mar 13, 2013 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.
    – Pylsa
    Commented Mar 13, 2013 at 23:02
  • 1
    @H.-DirkSchmitt: Frankly, I think the answer has merit, at least until we reach a consensus on meta. Commented Mar 13, 2013 at 23:31

2 Answers 2

5

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}"
2
  • what about Windows? Commented Mar 13, 2013 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:". Commented Mar 13, 2013 at 21:25
1

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

https://support.microsoft.com/kb/555737

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .