342

I am using windows 7 and xp. I want to know the uptime of the system.

What is the command / procedure for getting the uptime?

peterh
  • 11,875
  • 18
  • 85
  • 108
  • 5
    Err, are you looking for a command in command prompt? If you are, then try `net statistics server` in command prompt. – s0d4pop Jul 23 '12 at 05:12
  • 15
    Question to be posted in superuser – 000 Jul 23 '12 at 05:13
  • 1
    How to retrieve information about the system state from the command line is very clearly related to programming. – John Nov 20 '14 at 12:02
  • This question is answered on ServerFault: http://serverfault.com/questions/159612/windows-server-last-reboot-time –  Nov 20 '14 at 16:04
  • 1
    see also http://superuser.com/a/909172/33303 if you are interested in standby/hibernation too – Janus Troelsen Nov 17 '16 at 12:40
  • ok, I'm posting my answer here. The only working solution for me: press start button on your keyboard, then type control panel, now open the old style control panel from the start menu. Click networks and sharing. Find your active network connection. In general tab it will show a druation. Now this duration is the time this connection spent in active state, which only correlates quite well with the uptime as long as this is an autoconnect connection and you have not interfered with this connection since bootup. Not a 100% foolproof solution, but this is the only one that works correctly for me – Imre Nov 16 '19 at 09:09
  • if you have Node.js installed, node -p "os.uptime()" – Geng Jiawen Oct 27 '20 at 13:07
  • "net statistics Workstation" gave me among other things the time "statistics" started. I guess that is the same information as uptime on unix / MacOS. – Mark Patterson Apr 16 '21 at 03:31

3 Answers3

755

Following are eight ways to find the Uptime in Windows OS.

1: By using the Task Manager

In Windows Vista and Windows Server 2008, the Task Manager has been beefed up to show additional information about the system. One of these pieces of info is the server’s running time.

  1. Right-click on the Taskbar, and click Task Manager. You can also click CTRL+SHIFT+ESC to get to the Task Manager.
  2. In Task Manager, select the Performance tab.
  3. The current system uptime is shown under System or Performance ⇒ CPU for Win 8/10.

    "Up Time" field in Task Manager

2: By using the System Information Utility

The systeminfo command line utility checks and displays various system statistics such as installation date, installed hotfixes and more. Open a Command Prompt and type the following command:

systeminfo

You can also narrow down the results to just the line you need:

systeminfo | find "System Boot Time:"

enter image description here

3: By using the Uptime Utility

Microsoft have published a tool called Uptime.exe. It is a simple command line tool that analyses the computer's reliability and availability information. It can work locally or remotely. In its simple form, the tool will display the current system uptime. An advanced option allows you to access more detailed information such as shutdown, reboots, operating system crashes, and Service Pack installation.

Read the following KB for more info and for the download links:

To use it, follow these steps:

  1. Download uptime.exe from the above link, and save it to a folder, preferably in one that's in the system's path (such as SYSTEM32).
  2. Open an elevated Command Prompt window. To open an elevated Command Prompt, click Start, click All Programs, click Accessories, right-click Command Prompt, and then click Run as administrator. You can also type CMD in the search box of the Start menu, and when you see the Command Prompt icon click on it to select it, hold CTRL+SHIFT and press ENTER.
  3. Navigate to where you've placed the uptime.exe utility.
  4. Run the uptime.exe utility. You can add a /? to the command in order to get more options. enter image description here

It does not offer many command line parameters:

C:\uptimefromcodeplex\> uptime /?
usage: Uptime [-V]
    -V   display version

C:\uptimefromcodeplex\> uptime -V
version 1.1.0

3.1: By using the old Uptime Utility

There is an older version of the "uptime.exe" utility. This has the advantage of NOT needing .NET. (It also has a lot more features beyond simple uptime.)

Download link: Windows NT 4.0 Server Uptime Tool (uptime.exe) (final x86)

C:\uptimev100download>uptime.exe /?

UPTIME, Version 1.00
(C) Copyright 1999, Microsoft Corporation

Uptime [server] [/s ] [/a] [/d:mm/dd/yyyy | /p:n] [/heartbeat] [/? | /help]
        server          Name or IP address of remote server to process.
        /s              Display key system events and statistics.
        /a              Display application failure events (assumes /s).
        /d:             Only calculate for events after mm/dd/yyyy.
        /p:             Only calculate for events in the previous n days.
        /heartbeat      Turn on/off the system's heartbeat
        /?              Basic usage.
        /help           Additional usage information.

4: By using the NET STATISTICS Utility

Another easy method, if you can remember it, is to use the approximate information found in the statistics displayed by the NET STATISTICS command. Open a Command Prompt and type the following command:

net statistics workstation

The statistics should tell you how long it’s been running, although in some cases this information is not as accurate as other methods.

enter image description here

5: By Using the Event Viewer

Probably the most accurate of them all, but it does require some clicking. It does not display an exact day or hour count since the last reboot, but it will display important information regarding why the computer was rebooted and when it did so. We need to look at Event ID 6005, which is an event that tells us that the computer has just finished booting, but you should be aware of the fact that there are virtually hundreds if not thousands of other event types that you could potentially learn from.

Note: BTW, the 6006 Event ID is what tells us when the server has gone down, so if there’s much time difference between the 6006 and 6005 events, the server was down for a long time.

Note: You can also open the Event Viewer by typing eventvwr.msc in the Run command, and you might as well use the shortcut found in the Administrative tools folder.

  1. Click on Event Viewer (Local) in the left navigation pane.
  2. In the middle pane, click on the Information event type, and scroll down till you see Event ID 6005. Double-click the 6005 Event ID, or right-click it and select View All Instances of This Event.
  3. A list of all instances of the 6005 Event ID will be displayed. You can examine this list, look at the dates and times of each reboot event, and so on.
  4. Open Server Manager tool by right-clicking the Computer icon on the start menu (or on the Desktop if you have it enabled) and select Manage. Navigate to the Event Viewer.

enter image description here

5.1: Eventlog via PowerShell

Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005 -or $_.Id -eq 6006}

6: Programmatically, by using GetTickCount64

GetTickCount64 retrieves the number of milliseconds that have elapsed since the system was started.

7: By using WMI

wmic os get lastbootuptime

8: The new uptime.exe for Windows XP and up

Like the tool from Microsoft, but compatible with all operating systems up to and including Windows 10 and Windows Server 2016, this uptime utility does not require an elevated command prompt and offers an option to show the uptime in both DD:HH:MM:SS and in human-readable formats (when executed with the -h command-line parameter).

Additionally, this version of uptime.exe will run and show the system uptime even when launched normally from within an explorer.exe session (i.e. not via the command line) and pause for the uptime to be read:

enter image description here

and when executed as uptime -h:

enter image description here

Clonkex
  • 3,373
  • 7
  • 38
  • 55
Anil Kumar C
  • 1,604
  • 4
  • 22
  • 43
  • 2
    6. WMI : wmic os get lastbootuptime – ded' Nov 18 '13 at 20:37
  • 3
    Note for **Win XP / 2003**: **1.** not usable (not displayed in Task manager) **2.** may not include the boot time (not on my PC anyway), but the explicit uptime - contrary to later Windows systeminfo output. Note that systeminfo output is localized, so on a non-english Windows you need to replace the "System boot time" accordingly or just run `systeminfo` and check the whole output – FelixD Mar 25 '14 at 09:04
  • 58
    Now THAT is what I call a THOROUGH answer! :-) – Andrew Steitz May 26 '14 at 15:13
  • 2
    Please note that the uptime reported from "1: By using the Task Manager" can differ from the boot time, since it does not include the time spent in hibernation state. E.g. my PC was booted two days ago and reports only 8:20 of uptime. – user1708042 Mar 25 '15 at 07:39
  • 3
    Option 1 seems to be gone again in **Windows 8** Task Manager. – BlaM Apr 13 '15 at 08:56
  • 1
    @BlaM Task Manager -> Performance -> CPU. – Shadow Nov 01 '15 at 01:24
  • @shadow You're right. There is an "up time" there... Weirdly it tells me that the computer has been up for 17 days and 8 1/2 hours. It was off when I came to my office ~7 hours ago. I thought I *do* shut down my computer. The PC seems to think otherwise :) – BlaM Nov 02 '15 at 15:34
  • Weird. Maybe you just put it to sleep? – Shadow Nov 03 '15 at 02:40
  • The first option is my favorite. Been using Windows since the beginning and never knew that nugget was there. You learn something everyday! :D – Chiramisu Jan 03 '17 at 23:40
  • Uptime is not affected if you sleep or hibernate the computer. In other words, it is not a "true" uptime, how long windows have been running (unless you are sure it has not been hibernated). The net statistics workstation command shows how long the network card has been running. The date/time is usually a few seconds after the OS uptime date, but again not affected by hibernate/sleep. – nivs1978 Apr 20 '17 at 12:28
  • Thanks! It is very useful! It also worth mentioning that Event 6008 in EventLog indicates about unexpected shutdown. It can be caused by a hard reset or power loss. – Alek Nov 22 '17 at 10:42
  • Related with Event ID 6013: https://serverfault.com/a/702829/145950 – Ivan Chau Jan 02 '18 at 10:28
  • Great Answer! slight correction for #2 on windows xp sp3 and maybe other windows os: systeminfo | find "System Up Time:" – Dany Balian Feb 22 '18 at 12:21
  • These answers give a mishmash of results. Some of them return the total amount of time since the system was booted, others give the amount of time the system was running, not including sleep/standby/hibernation. They are not all the same. – Synetech Mar 29 '21 at 02:43
17

I use this little PowerShell snippet:

function Get-SystemUptime {
    $operatingSystem = Get-WmiObject Win32_OperatingSystem
    "$((Get-Date) - ([Management.ManagementDateTimeConverter]::ToDateTime($operatingSystem.LastBootUpTime)))"
}

which then yields something like the following:

PS> Get-SystemUptime
6.20:40:40.2625526
Joey
  • 344,408
  • 85
  • 689
  • 683
9

Two ways to do that..

Option 1:

1.  Go to "Start" -> "Run".

2.  Write "CMD" and press on "Enter" key.

3.  Write the command "net statistics server" and press on "Enter" key.

4.  The line that start with "Statistics since …" provides the time that the server was up from.


  The command "net stats srv" can be use instead.

Option 2:

Uptime.exe Tool Allows You to Estimate Server Availability with Windows NT 4.0 SP4 or Higher

http://support.microsoft.com/kb/232243

Hope it helped you!!

Praveen Govind
  • 2,619
  • 2
  • 32
  • 45
  • your suggested link is broken. You can try another way for broken link as below; [link](http://web.archive.org/web/20100316211056/http:/download.microsoft.com/download/winntsrv40/install/uptime_1.01/nt4/en-us/uptime.exe) Internet Archive URL or [link](https://networkproguide.com/wp-content/uploads/uptime.zip). – NCC1701 Mar 17 '22 at 08:30