This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 11 years ago.
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
接受
或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
发布评论
评论(6)
PowerShell 和系统事件日志非常适合此任务。请注意,ID 为 12 的事件是系统启动事件,而 ID 13 表示系统关闭事件。以下 PowerShell 脚本将提供系统在一个月内的启动和关闭时间。
将
12/21/2011
替换为您想要的任何日期。单击“开始”菜单,键入“powershell”,然后输入将启动 Windows PowerShell。PowerShell and System Event Log are perfectly designed for this task. Note events with id 12 is a System Start Up event while an id 13 indicates System Shutdown. The following PowerShell script will provide the start and shutdown time of your system in one month.
Substitute the
12/21/2011
to any date you wish. Click Start Menu, type "powershell" and then enter will launch Windows PowerShell.在 Windows XP 中,只需键入
It 即可显示系统运行时间。
it is possible in windows xp just type
It will display system up time.
以下是检查系统启动\
正常运行时间
的步骤。启动任务管理器
”,或者转到开始菜单运行命令并键入“taskmgr.exe”,然后按 Enter 键) 。Perfomance
选项卡System
组,然后它会在 DD::HH::MM:: 中显示
Uptime
SS 格式。Here are the following steps to checking your systems startup \
uptime
.Start Task Manager
", or from going to your start menus run command and typing "taskmgr.exe", then hitting enter).Perfomance
tabSystem
group near the bottom middleIt will then say
Uptime
in DD::HH::MM::SS format.要找出这些信息,您可以编写一个程序来 grep 通过事件日志
To figure out this information, you can write a program to grep through the Event Log
如果您试图记录所有启动和关闭时间的日志,您将需要某种日志。您可以自己编写一个,也可以查看 Microsoft 在 Windows 7 中提供的内容。为此,请查看以下教程。
http://www.sevenforums.com /tutorials/177443-gathering-startup-shutdown-sleep-hibernate-reboot-trace.html
If you are attempting to have logs of all your startup and shutdown times, you are going to want some kind of a log. You can either write one your self, or you can take a look at what Microsoft has provided in Windows 7. To do so, take a look at the following tutorial.
http://www.sevenforums.com/tutorials/177443-gathering-startup-shutdown-sleep-hibernate-reboot-trace.html
您想通过编程代码来做到这一点吗?就像在 C/C++ 代码中一样?
GetTickCount64()返回自系统启动以来的毫秒数。仅限 Vista 及更高版本。 (所以这应该适用于 Windows 7)。
如果您必须在早于 Vista 或 Win2K8 服务器的操作系统上运行,则可以使用普通的旧 GetTickCount() - 在 49.7 天左右后循环回零。
然后使用其他时间/日期函数来获取当前时间。从当前时间减去 GetTickCount 或 GetTickCount64 返回的值。那是系统最后一次启动的时间。
Did you want to do this via programming code. As in C/C++ code?
GetTickCount64() returns the number of milliseconds since the system was started. Vista and up only. (So this should work for Windows 7).
If you have to run on operating systems older than Vista or Win2K8 server, there's plain old GetTickCount() - which loops back to zero after 49.7 days or so.
Then use the other time/date functions to get the current time. Subtract the value returned by GetTickCount or GetTickCount64 from the current time. That's when the system was last started up.