Find Windows system uptime from the command line

by admin on September 1, 2009

Here’s a quick and easy way of checking how long a Windows server or workstation has been up, via the command line.  It pipes the results of Net Statistics Workstation into find.  Run the following from a command prompt:

net statistics workstation | find /i “statistics since”

The results will look like

Statistics since 8/12/2009 11:08 PM

Which shows the machine has been up since 11:08pm on August 12, 2009.

{ 15 comments… read them below or add one }

Andrew September 1, 2009 at 4:08 pm

Nice! I didn’t know about that. I use:

systeminfo | findstr Time:

Cheers,

Reply

Andrew September 1, 2009 at 11:50 pm

Just worked out that the explicit version of that is:

systeminfo | findstr /bc:”System Up Time”

Cheers,

Reply

Julie September 2, 2009 at 7:21 am

Problem with this is it doesn’t always return a value. When I do this on my Windows XP SP2 machine the following is returned, not sure why.

System Up Time: N/A

-Julie

Reply

alMubarmij January 21, 2010 at 2:06 pm

I have the same problem, and I upgraded my XP system for SP2 to SP3, but the problem not fixed.

Anyone has an idea for this ?

Reply

andy September 1, 2009 at 7:35 pm

Most systems will also work with a

dir c:\ /ah

and look at the time stamp for pagefile.sys (obviously relies on the pagefile being on c:)

Reply

CypherBit September 2, 2009 at 2:51 am

This also works: systeminfo | findstr /c:”System Boot Time”

Reply

Julie September 2, 2009 at 7:22 am

CypherBit-

On Windows XP it’s actually
systeminfo | findstr /c:”System Up Time”

systeminfo | findstr /c:”System Boot Time”
does not return anything

-Julie

Reply

CypherBit September 2, 2009 at 7:36 am

Indeed, I only did a quick test on Vista…why they change things like that is beyond me.

Reply

Sahmeepee September 19, 2009 at 8:02 am

The “systeminfo” and “net statistics” methods both have their own advantages:

Net statistics:

Runs more quickly
Gives the date and time the machine started*

Systeminfo:
Can be run against a remote machine (without psexec etc.)
Gives the time since the machine started*

*This depends on your preference

Reply

Sahmeepee September 19, 2009 at 8:04 am

I should also say that net statistics is slightly evil because it shows dates in US format, regardless of the regional settings in Windows. Why can’t everyone use ISO formats?!

Reply

aig1979 October 2, 2009 at 10:43 pm

the net stat command will only show when the network was started. This command will work across all platforms.

Systeminfo looks like it depends on the version. You can always script it and check the version of the OS that is running. Then check the value.

Reply

Sahmeepee October 5, 2009 at 7:05 pm

WMI is rather good too. Here’s the wmi version using the native tool WMIC:

wmic OS Get LastBootUpTime | findstr +

(advantage: outputs in ISO date format)

Reply

Andy N October 22, 2009 at 6:10 pm

Uptime.exe from the NT4 Resource Kit – It “does what it says on the tin”, and also calculates availability statistics for arbitrary time horizons. Haven’t tried it under 2K8 yet.

Reply

Jay October 29, 2009 at 1:23 am

Thanks for the info on how to get system uptime.

For the record I wonder how many others got NOTHING that is N/A showing on a just booted XP on the
Sytem Up Time:
line from the systeminfo command?

Net statistics workstation

worked great though, and

DIR C:\ /ah

also good plus the added bonus of being at the level of technical trivia knowledge.

Jay

Reply

Carl January 18, 2010 at 8:44 am

Doesn’t work on XP SP3 at least, find parameter is wrong it informs.

net statistics workstation | find “Statistics since”

seems to work just fine though.

Reply

Leave a Comment

{ 1 trackback }

Previous post:

Next post: