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.
September 1, 2009 at 4:08 pm
Nice! I didn’t know about that. I use:
systeminfo | findstr Time:
Cheers,
September 1, 2009 at 11:50 pm
Just worked out that the explicit version of that is:
systeminfo | findstr /bc:”System Up Time”
Cheers,
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
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:)
September 1, 2009 at 11:54 pm
[...] for this post goes to Julie @ thebackroom tech blog ( http://thebackroomtech.com/2009/09/01/find-windows-system-uptime-from-the-command-line/ ) Leave a [...]
September 2, 2009 at 2:51 am
This also works: systeminfo | findstr /c:”System Boot Time”
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
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.
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
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?!
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.
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)
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.
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