本文翻译自:How to get the system uptime in Windows? [closed]
I am using windows 7 and xp. 我正在使用Windows 7和XP。 I want to know the uptime of the system. 我想知道系统的正常运行时间。
What is the command / procedure for getting the uptime? 获取正常运行时间的命令/程序是什么?
#1楼
参考:https://stackoom.com/question/mhS2/如何在Windows中获得系统正常运行时间-关闭
#2楼
Two ways to do that.. 两种方法......
Option 1: 选项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: 选项2:
Uptime.exe Tool Allows You to Estimate Server Availability with Windows NT 4.0 SP4 or Higher Uptime.exe工具允许您使用Windows NT 4.0 SP4或更高版本估计服务器可用性
http://support.microsoft.com/kb/232243 http://support.microsoft.com/kb/232243
Hope it helped you!! 希望它能帮到你!!
#3楼
Following are eight ways to find the Uptime in Windows OS. 以下是在Windows操作系统中查找Uptime的八种方法。
1: By using the Task Manager 1:使用任务管理器
In Windows Vista and Windows Server 2008, the Task Manager has been beefed up to show additional information about the system. 在Windows Vista和Windows Server 2008中,任务管理器已经增强,以显示有关系统的其他信息。 One of these pieces of info is the server's running time. 其中一条信息是服务器的运行时间。
- Right-click on the Taskbar, and click Task Manager. 右键单击任务栏,然后单击“任务管理器”。 You can also click CTRL + SHIFT + ESC to get to the Task Manager. 您也可以单击CTRL + SHIFT + ESC进入任务管理器。
- In Task Manager, select the Performance tab. 在任务管理器中,选择“性能”选项卡。
The current system uptime is shown under System or Performance ⇒ CPU for Win 8/10. 当前系统正常运行时间显示在系统或性能⇒CPUfor Win 8/10下。
2: By using the System Information Utility 2:使用系统信息实用程序
The systeminfo
command line utility checks and displays various system statistics such as installation date, installed hotfixes and more. systeminfo
命令行实用程序检查并显示各种系统统计信息,例如安装日期,已安装的修补程序等。 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 3:使用Uptime Utility
Microsoft have published a tool called Uptime.exe. 微软已经发布了一个名为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. 高级选项允许您访问更详细的信息,如关机,重新启动,操作系统崩溃和Service Pack安装。
Read the following KB for more info and for the download links: 阅读以下KB以获取更多信息和下载链接:
- MSKB232243: Uptime.exe Tool Allows You to Estimate Server Availability with Windows NT 4.0 SP4 or Higher . MSKB232243: Uptime.exe工具允许您使用Windows NT 4.0 SP4或更高版本估计服务器可用性 。
To use it, follow these steps: 要使用它,请按照下列步骤操作:
- 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). 从上面的链接下载uptime.exe,并将其保存到一个文件夹中,最好是在系统路径中的文件夹中(例如SYSTEM32)。
- 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 . 您也可以在“开始”菜单的搜索框中键入CMD,当您看到“命令提示符”图标时单击它以选择它,按住CTRL + SHIFT并按Enter 。
- Navigate to where you've placed the uptime.exe utility. 导航到您放置uptime.exe实用程序的位置。
- Run the
uptime.exe
utility. 运行uptime.exe
实用程序。 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 3.1:使用旧的Uptime实用程序
There is an older version of the "uptime.exe" utility. 有一个旧版本的“uptime.exe”实用程序。 This has the advantage of NOT needing .NET. 这具有不需要.NET的优点。 (It also has a lot more features beyond simple uptime.) (除了简单的正常运行时间外,它还具有更多功能。)
Download link: Windows NT 4.0 Server Uptime Tool (uptime.exe) (final x86) 下载链接: Windows NT 4.0 Server Uptime Tool(uptime.exe)(最终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 4:使用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. 另一种简单的方法,如果你能记住它,就是使用NET STATISTICS命令显示的统计信息中的近似信息。 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 5:使用事件查看器
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. 我们需要查看事件ID 6005,这是一个告诉我们计算机刚刚完成启动的事件,但是你应该知道,你可以从中学到几乎数百个甚至数千个其他事件类型。 。
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. 注意:BTW,6006事件ID告诉我们服务器什么时候出现故障,所以如果6006和6005事件之间存在很大的时间差,服务器会长时间停机。
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. 注意:您还可以通过在“运行”命令中键入eventvwr.msc来打开“事件查看器”,也可以使用“管理工具”文件夹中的快捷方式。
- Click on Event Viewer (Local) in the left navigation pane. 单击左侧导航窗格中的“事件查看器(本地)”。
- 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. 在中间窗格中,单击“信息”事件类型,然后向下滚动直至看到事件ID 6005.双击6005事件ID,或右键单击它并选择“查看此事件的所有实例”。
- A list of all instances of the 6005 Event ID will be displayed. 将显示6005事件ID的所有实例的列表。 You can examine this list, look at the dates and times of each reboot event, and so on. 您可以检查此列表,查看每个重新启动事件的日期和时间,等等。
- 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 5.1:通过PowerShell的事件日志
Get-WinEvent -ProviderName eventlog | Where-Object {$_.Id -eq 6005 -or $_.Id -eq 6006}
6: Programmatically, by using GetTickCount64 6:使用GetTickCount64以编程方式
GetTickCount64 retrieves the number of milliseconds that have elapsed since the system was started. GetTickCount64检索自系统启动以来经过的毫秒数。
7: By using WMI 7:使用WMI
wmic os get lastbootuptime
8: The new uptime.exe for Windows XP and up 8:适用于Windows XP及更高版本的新uptime.exe
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). 与Microsoft的工具一样,但与Windows 10和Windows Server 2016之间的所有操作系统兼容, 此正常运行时间实用程序不需要提升的命令提示符,并提供一个选项以显示DD中的正常运行时间:HH:MM:SS并以人类可读的格式(使用-h
命令行参数执行时)。
Additionally, this version of uptime.exe
will run and show the system uptime even when launched normally from within an explorer.exe session (ie not via the command line) and pause for the uptime to be read: 此外,此版本的uptime.exe
将运行并显示系统正常运行时间,即使从explorer.exe会话中正常启动(即不通过命令行)并暂停以便读取正常运行时间:
and when executed as uptime -h
: 当作为uptime -h
执行时uptime -h
:
#4楼
I use this little PowerShell snippet: 我使用这个小PowerShell片段:
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