Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)

like image 436
peterchen Avatar asked Jan 23 '23 19:01

peterchen


2 Answers

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.

like image 182
Adam Avatar answered Jan 25 '23 09:01

Adam


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?

like image 30
Carl Smotricz Avatar answered Jan 25 '23 10:01

Carl Smotricz