如何在 Windows 中获得系统正常运行时间? [英] How to get the system uptime in Windows?

查看:52
本文介绍了如何在 Windows 中获得系统正常运行时间?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是 windows 7 和 xp.我想知道系统的正常运行时间.

获取正常运行时间的命令/程序是什么?

解决方案

以下是在 Windows 操作系统中查找正常运行时间的八种方法.

1:使用任务管理器

在 Windows Vista 和 Windows Server 2008 中,任务管理器得到了加强,可以显示有关系统的附加信息.这些信息之一是服务器的运行时间.

  1. 右键单击任务栏,然后单击任务管理器.您也可以单击 CTRL+SHIFT+ESC 进入任务管理器.
  2. 在任务管理器中,选择性能"选项卡.
  3. 当前系统正常运行时间显示在系统或性能 ⇒ 下.适用于 Win 8/10 的 CPU.

2:使用系统信息实用程序

systeminfo 命令行实用程序检查并显示各种系统统计信息,例如安装日期、安装的修补程序等.打开命令提示符并键入以下命令:

系统信息

您还可以将结果缩小到您需要的行:

systeminfo |找到系统启动时间:"

3:使用正常运行时间工具

Microsoft 发布了一个名为 Uptime.exe 的工具.它是一个简单的命令行工具,用于分析计算机的可靠性和可用性信息.它可以在本地或远程工作.该工具以简单的形式显示当前系统的正常运行时间.高级选项允许您访问更详细的信息,例如关机、重新启动、操作系统崩溃和 Service Pack 安装.

阅读以下 KB 以获取更多信息和下载链接:

  • MSKB232243:

    C:\uptimev100download>uptime.exe/?正常运行时间,版本 1.00(C) 版权所有 1999,微软公司正常运行时间 [服务器] [/s] [/a] [/d:mm/dd/yyyy |/p:n] [/heartbeat] [/?|/帮助]server 要处理的远程服务器的名称或 IP 地址./s 显示关键系统事件和统计信息./a 显示应用程序失败事件(假设为/s)./d:仅计算 mm/dd/yyyy 之后的事件./p:只计算前 n 天的事件./heartbeat 打开/关闭系统的心跳/?基本用法./help 附加使用信息.

    4:使用 NET STATISTICS 实用程序

    如果您还记得的话,另一个简单的方法是使用 NET STATISTICS 命令显示的统计信息中的近似信息.打开命令提示符并键入以下命令:

    网络统计工作站

    统计信息应该告诉您它运行了多长时间,尽管在某些情况下,此信息不如其他方法准确.

    5:使用事件查看器

    可能是其中最准确的,但确实需要点击一下.它不会显示自上次重新启动以来的确切天数或小时数,但会显示有关计算机重新启动的原因和时间的重要信息.我们需要查看事件 ID 6005,这是一个告诉我们计算机刚刚完成启动的事件,但您应该意识到事实上有数百甚至数千种其他事件类型可供您学习.

    注意:顺便说一句,6006 事件 ID 是告诉我们服务器何时宕机,所以如果 6006 和 6005 事件之间的时间差很大,则服务器宕机了很长时间.

    注意:您还可以通过在运行命令中键入 eventvwr.msc 来打开事件查看器,您也可以使用在管理工具文件夹中找到的快捷方式.

    1. 点击左侧导航窗格中的事件查看器(本地).
    2. 在中间窗格中,单击信息事件类型,然后向下滚动直到看到事件 ID 6005.双击 6005 事件 ID,或右键单击它并选择查看此事件的所有实例.
    3. 将显示 6005 事件 ID 的所有实例的列表.您可以检查此列表,查看每个重启事件的日期和时间,等等.
    4. 右键单击开始菜单(或桌面上,如果已启用)上的计算机图标,打开服务器管理器工具,然后选择管理.导航到事件查看器.

    5.1:通过 PowerShell 的事件日志

    Get-WinEvent -ProviderName 事件日志 |Where-Object {$_.Id -eq 6005 -or $_.Id -eq 6006}

    6:以编程方式,使用

    当作为 uptime -h 执行时:

    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?

    解决方案

    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.

    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:"
    

    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.

    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.

    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.

    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:

    and when executed as uptime -h:

    这篇关于如何在 Windows 中获得系统正常运行时间?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆