views:

71

answers:

3
+4  Q: 

Identify a reboot

Is there any "Boot session ID" or (reliable) "Boot timestamp"? For an installation I need to detect that a scheduled reboot took place indeed.

I guess I could do a dummy MoveFileEx() with MOVEFILE_DELAY_UNTIL_REBOOT, but i did hope for something easier.

(We have to install a 3rd party package that sometimes behaves erratically after an repair/update. In that state, accessing the device may even lock up the system)

(Windows XP, Vista, 7)

+3  A: 

Apparently Windows has the equivalent of "uptime". Here's more info: http://support.microsoft.com/kb/555737

As I understand it, this should tell you how long ago the system was booted. Will that information solve your problem?

Carl Smotricz
That's a good start - I found an updated sample (haven't tried yet) here: http://www.codeproject.com/Messages/2109755/Re-Not-working-on-Vista-Any-ideas-modified.aspx
peterchen
+3  A: 

For things like this, WMI (Windows Management Instrumentation) is often a good starting place. I know you can get current uptime directly through it, which may allow you to determine if a machine recently rebooted.

Here is a blog post with some code samples as well: http://blogs.technet.com/heyscriptingguy/archive/2004/09/07/how-can-i-tell-if-a-server-has-rebooted.aspx

Depending on your implementation language, you probably just want to pull out the query code from the vbscript.

Adam
+1  A: 

You could search the System event log for event 6009 from the EventLog source - this is the first event recorded after each reboot.

Damien_The_Unbeliever