I want to check the operating system's start time. That is, for the last one month, the times when Windows was booted up. Is it possible to find this out?
6 Answers
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.
echo "Start time:"
Get-EventLog System -After 12/21/2011 | ? {$_.EventId -eq 12} | % {$_.TimeGenerated}
echo "Shutdown time:"
Get-EventLog System -After 12/21/2011 | ? {$_.EventId -eq 13} | % {$_.TimeGenerated}
Substitute the 12/21/2011
to any date you wish. Click Start Menu, type "powershell" and then enter will launch Windows PowerShell.

- 30,738
- 21
- 105
- 131

- 1,594
- 10
- 21
-
This is even better than my idea – Ana Betts Jan 22 '12 at 06:13
-
@grapeot When i execute the command it gives following error message `Get-EventLog : Cannot bind parameter 'After'. Cannot convert value "12/21/2011" to type "System.DateTime". Error: "Stri ng was not recognized as a valid DateTime." At line:1 char:27 + Get-EventLog System -After <<<< 12/21/2011 | ? {$_.EventId -eq 12} | % {$_.TimeGenerated} + CategoryInfo : InvalidArgument: (:) [Get-EventLog], ParameterBindingException + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Microsoft.PowerShell.Commands.GetEventLogCommand` – Bhavik Ambani Jan 22 '12 at 07:19
-
I suppose this is because you are using PowerShell 1.0 rather than the latest 2.0. Could you please try `Get-EventLog System -After ([DateTime]::Parse('12/21/2011')) | ? {$_.EventId -eq 12} | % {$_.TimeGenerated}`? Note we change `12/21/2011` into `([DateTime]::Parse('12/21/2011'))`. Please let me know if this still doesn't work. I'm sorry but I don't have PS 1.0 environment at hand. Or if you wish, you can upgrade to PS 2.0 with [this patch](http://support.microsoft.com/kb/968929). – grapeot Jan 22 '12 at 07:29
-
Thanks but still it gives me this error `Exception calling "Parse" with "1" argument(s): "String was not recognized as a valid DateTime." At line:1 char:46 + Get-EventLog System -After ([DateTime]::Parse <<<< ('12/21/2011')) | ? {$_.Ev entId -eq 12} | % {$_.TimeGenerated} + CategoryInfo : NotSpecified: (:) [], MethodInvocationException + FullyQualifiedErrorId : DotNetMethodException ` – Bhavik Ambani Jan 22 '12 at 07:57
-
I am sorry but currently I don't know where is the problem... It passed the test in my PS 2.0 and Windows 7... Or could you please try the following code: `Get-EventLog System -Newest 10000 | ? {$_.EventId -eq 12} | % {$_.TimeGenerated}`? By this way we can avoid the `DateTime` problem. But this code is actually parsing the latest 10000 events, you may need to adjust the event number to make the result include the last month. – grapeot Jan 22 '12 at 09:30
-
Never use local date strings in examples. Always use ISO format, like 2011-12-21, or you will encounter lots of problems with people who have non-American date formats. – SilverbackNet Aug 27 '18 at 21:29
-
It doesn't even need a hardcoded date anyway, (Get-Date).AddMonths(-1) is the general answer. – SilverbackNet Aug 27 '18 at 21:31
it is possible in windows xp just type
systeminfo| find "System Up Time"
It will display system up time.

- 6,970
- 12
- 53
- 84
Here are the following steps to checking your systems startup \ uptime
.
- Open up task manager (either from alt+ctrl+del, then clicking on "
Start Task Manager
", or from going to your start menus run command and typing "taskmgr.exe", then hitting enter). - Click on the
Perfomance
tab - Look for the
System
group near the bottom middle
It will then say Uptime
in DD::HH::MM::SS format.

- 38,876
- 35
- 121
- 169

- 3,256
- 15
- 20
-
Thanks for the post but I dont want uptime of the system, I want the time when system was started and shutdown for the last one month. But here it gives only the uptime same. – Bhavik Ambani Jan 22 '12 at 05:33
-
I am sorry, I must have interpreted your question wrong. I posted what is hopefully a more appropriate answer down below. – josephthomas Jan 22 '12 at 05:43
To figure out this information, you can write a program to grep through the Event Log

- 73,868
- 16
- 141
- 209
-
But please give me code to write, I am not aware of any of the code – Bhavik Ambani Jan 22 '12 at 05:41
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.

- 3,256
- 15
- 20
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.

- 100,020
- 15
- 103
- 173
-
I dont want to know the current days system startuo time, If I wanted that then mechanism sugggested by josephthomas in answers is good, but I want to know the system boot time for the last say for example one month etc. – Bhavik Ambani Jan 22 '12 at 08:18
-
@BhavikAmbani -You wanted to find the list of all the different times the system was (re)started? That was not obvious based on the title of your question. You want "times" not "the time". – selbie Jan 22 '12 at 08:24