Discussion:
Is it possible to determine (programmatically) if system was just powered up or rebooted
(too old to reply)
Boris
2010-07-10 22:40:34 UTC
Permalink
Hi,

I'm thinking about writing custom Native EXE that will be executed early
during Windows boot process. I'll put pathname of my Native EXE into
BootExecute value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key. But
I need to tell "cold" boot from "warm" boot: if hardware was powered on or
just Windows restarted.
Is there a way of doing this?

Thanks,
Boris
Boris
2010-07-10 22:52:03 UTC
Permalink
The operating systems in question are: XP SP3 (or XP Embedded Standard),
Win7 (or Win 7 Embedded).

Thanks,
Boris
Post by Boris
Hi,
I'm thinking about writing custom Native EXE that will be executed early
during Windows boot process. I'll put pathname of my Native EXE into
BootExecute value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key.
But I need to tell "cold" boot from "warm" boot: if hardware was powered
on or just Windows restarted.
Is there a way of doing this?
Thanks,
Boris
a
2010-07-11 17:14:47 UTC
Permalink
The operating systems in question are: XP SP3 (or XP Embedded Standard), Win7 (or Win 7 Embedded).
Thanks,
Boris
Hi,
I'm thinking about writing custom Native EXE that will be executed early during Windows boot process. I'll put pathname of my
Native EXE into BootExecute value in HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key. But I need to tell
"cold" boot from "warm" boot: if hardware was powered on or just Windows restarted.
Is there a way of doing this?
I was going to say just check the value of GetTickCount(), but that's no
good if the user has rebooted the PC. Maybe check that once, and store a
flag value somewhere (with the date) so that subsequent checks on the same
day know that the PC has already been previously started that day? That
should work fine.
Boris
2010-07-13 07:04:53 UTC
Permalink
Post by a
Post by Boris
The operating systems in question are: XP SP3 (or XP Embedded Standard),
Win7 (or Win 7 Embedded).
Thanks,
Boris
Post by Boris
Hi,
I'm thinking about writing custom Native EXE that will be executed early
during Windows boot process. I'll put pathname of my Native EXE into
BootExecute value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key.
But I need to tell "cold" boot from "warm" boot: if hardware was powered
on or just Windows restarted.
Is there a way of doing this?
I was going to say just check the value of GetTickCount(), but that's no
good if the user has rebooted the PC. Maybe check that once, and store a
flag value somewhere (with the date) so that subsequent checks on the same
day know that the PC has already been previously started that day? That
should work fine.
Thanks for the response - but I don't think so. GetTickCount() counter is
reset to 0 each time OS boots - you cannot tell cold boot from warm boot
that way. It's possible, some HAL lib functions can extract that info from
system BIOS - but I couldn't find anything relevant.

Boris
Simon Richter
2010-07-13 09:00:19 UTC
Permalink
Hi,
Post by Boris
Thanks for the response - but I don't think so. GetTickCount() counter
is reset to 0 each time OS boots - you cannot tell cold boot from warm
boot that way. It's possible, some HAL lib functions can extract that
info from system BIOS - but I couldn't find anything relevant.
Also consider that the BIOS considers pressing the reset button a cold boot.

Your best bet would be to look at the timestamps of the events
preceeding the reboot in the events log.

I also have the usual feeling of this being a minor part of a solution
to a larger problem, where it is not entirely clear that the solution
itself is sound (i.e. what are you trying to do, really?)

Simon
a
2010-07-13 13:27:09 UTC
Permalink
Post by a
I was going to say just check the value of GetTickCount(), but that's no
good if the user has rebooted the PC. Maybe check that once, and store a
flag value somewhere (with the date) so that subsequent checks on the same
day know that the PC has already been previously started that day? That
should work fine.
Thanks for the response - but I don't think so. GetTickCount() counter is reset to 0 each time OS boots - you cannot tell cold
boot from warm boot that way. It's possible, some HAL lib functions can extract that info from system BIOS - but I couldn't find
anything relevant.
Upon thinking about it more, I was close in my tip above anyway. All you need
to do is: when Windows boots, check if a file called "<date>" exists in your
app's folder. If not, then the app assumes it's the first boot of the day and
creates the file, so any subsequents reboots on the same day can be identified.

And if the file "<date>" does NOT exist when your app starts at bootup, then
your app knows it IS the first boot of the day, and creates the file to mark
the boot as "known". Your app then deletes any "<date>" files from the past,
to keep the PC clean.

This will work fine.
Don Burn
2010-07-13 10:47:56 UTC
Permalink
You can find out in a driver from the power state transitions what the
user intended to do at shutdown, but this does not ensure that you will
get the result. For instance, the person who chooses reboot then pulls
the power. If you can live with that restriction, there are approaches,
otherwise the comments so far are probably about all you can do.


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
-----Original Message-----
Posted At: Saturday, July 10, 2010 6:41 PM
Posted To: microsoft.public.development.device.drivers
Conversation: Is it possible to determine (programmatically) if system
was
just powered up or rebooted
Subject: Is it possible to determine (programmatically) if system was
just
powered up or rebooted
Hi,
I'm thinking about writing custom Native EXE that will be executed early
during Windows boot process. I'll put pathname of my Native EXE into
BootExecute value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager
key. But I
need to tell "cold" boot from "warm" boot: if hardware was powered on
or just
Windows restarted.
Is there a way of doing this?
Thanks,
Boris
__________ Information from ESET Smart Security, version of virus
signature
database 5268 (20100710) __________
The message was checked by ESET Smart Security.
http://www.eset.com
Bob Masta
2010-07-13 12:01:01 UTC
Permalink
On Sat, 10 Jul 2010 15:40:34 -0700, "Boris"
Post by Boris
Hi,
I'm thinking about writing custom Native EXE that will be executed early
during Windows boot process. I'll put pathname of my Native EXE into
BootExecute value in
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager key. But
I need to tell "cold" boot from "warm" boot: if hardware was powered on or
just Windows restarted.
Is there a way of doing this?
Maybe no longer relevant, but:

Back in the Good Old Days of DOS, the BIOS set the word at
0x0472 to 0x1234 after the initial power-up memory test. If
you did a warm boot via CTRL-ALT-DEL and the memory test
code found this word already set to 0x1234, it skipped the
memory test (which used to be rather lengthy on some of
those old machines). You could force a "cold boot" memory
test by setting this word to some other value.

I don't know if the BIOS still does anything with this word,
or even if there is still a memory test (other than sizing).
But it might be something to look into if nothing else
turns up.

Best regards,


Bob Masta

DAQARTA v5.10
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
DaqMusic - FREE MUSIC, Forever!
(Some assembly required)
Science (and fun!) with your sound card!
Maxim S. Shatskih
2010-07-13 17:21:41 UTC
Permalink
Post by Bob Masta
or even if there is still a memory test (other than sizing).
Yes, memory tests are still here.
--
Maxim S. Shatskih
Windows DDK MVP
***@storagecraft.com
http://www.storagecraft.com
Don Burn
2010-07-13 17:25:31 UTC
Permalink
The memory test may be there, but I doubt there is any way to get it by
the time a native program runs.


Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr
-----Original Message-----
Posted At: Tuesday, July 13, 2010 1:22 PM
Posted To: microsoft.public.development.device.drivers
Conversation: Is it possible to determine (programmatically) if system
was
just powered up or rebooted
Subject: Re: Is it possible to determine (programmatically) if system
was just
powered up or rebooted
Post by Bob Masta
or even if there is still a memory test (other than sizing).
Yes, memory tests are still here.
--
Maxim S. Shatskih
Windows DDK MVP
http://www.storagecraft.com
__________ Information from ESET Smart Security, version of virus
signature
database 5275 (20100713) __________
The message was checked by ESET Smart Security.
http://www.eset.com
Loading...