Occasionally, when I’m working on a server, I need to check its uptime. I can find this information using several different ways, but often I’m in the middle of the command line session and I don’t want to leave my keyboard and search for the mouse.
At such times, using the command line is the best way to achive the goal. I will show you the two handy ways in which you can do this.
I used these commands on different Windows versions, from Windows XP up to Windows 10 and Server 2016. The NET command should work even on older Windows version, including Windows NT 4.0. The WMIC command should work also on Window 2000 platform.
The NET command
The command NET originates from a very old Windows command line interfaces. Actually, the NET command has a lot of subcommands and it’s very powerful when we want to obtain network related information.
We have the context NET STATISTICS where we can get the statistics of either the server or workstation service. We can use this command even from within a batch file and we can filter the output using the find command.
There is an abbreviate version of this command – net stats. Additionally, we can shorten server to srv, and workstation to work.
Open the command prompt and type:
net stats srv
In case that server service is not running, you can type
net stats work
We will have a response similar to this one:
C:\>net stats server Server Statistics for \\DELPHI3 Statistics since 2017-06-16 21:13 Sessions accepted 1 Sessions timed-out 0 Sessions errored-out 0 Kilobytes sent 0 Kilobytes received 0 Mean response time (msec) 0 System errors 0 Permission violations 0 Password violations 0 Files accessed 0 Communication devices accessed 0 Print jobs spooled 0 Times buffers exhausted Big buffers 0 Request buffers 0 The command completed successfully. C:\>
We can see a lot of information about the server service, like the number of sessions or accessed files, the print jobs, and so on.
The most interesting part for us is the line beginning with Statistics since. There we can see the Windows start date and time.
However, if you’re not interested in reading a short book on this screen, you can utilize some magic and mighty tricks. We can use the output redirection and the command find, if we type this command:
C:\>net stats srv | find "since " Statistics since 2017-06-16 21:13 C:\>
The WMIC command
The WMIC interface was introduced with Windows 2000 as the command line shell to the WMI subsystem. The WMI subsystem contains all the information about the local Windows machine. You can get information like Windows version, memory, computer serial number, etc.
Furthermore, it can access remote Windows machines and read their information too. This is very useful trick if you need to check multiple machines from your computer. Just add /node:computername after the wmic command.
In this case, we need the OS context and the value of the property named LastBootUpTime. Our command for the local machine will be:
C:\> wmic os get LastBootUpTime
You can type everything in lower case (my example below differs simply to highlighted the parameter name). The request will be processed and you should see response like
LastBootUpTime 20170616211330.009749+120 C:\>
As you can see, we have a similar output to the previous command.
The output of the WMIC command will always be the same, regardless of your local date and time format. It’s in the form of 4-digit year, the two digits for month, day, hour, minutes and seconds. The milliseconds are displayed after the dot.
In our example, we have the value 20170616211330.009749+120. This means that the last system boot was on June 16th 2017 (2017 06 16) at 21:13:30.009749 hours.
I reveled two simple yet mighty tricks to find the system’s uptime in a split second. Use the version that suits your needs.
I encourage you to investigate other parameters of the WMIC command – it may well save your day.