I have a weird scenario that I’m not sure how to work around.
It starts when a user upgrades our drivers and whatnot for a system that has
our card in it. We then reboot the system. When our new drivers come up,
they may notice that a firmware or FPGA upgrade might need to be done to the
hardware (depending on the rev of the hardware and previous upgrades that
may have been done), so we will upgrade that. However, we then need to do
another reboot of the system to get the hardware / drivers going again, so
we call InitiateSystemShutdown. However, in the meantime, the user may have
logged in manually or due to AutoAdminLogon, so the system may be logged in
and processing RunOnce keys and so on. A few times, we’ve seen that the
system then gets a bit messed up due to us rebooting the system in the
middle of some RunOnce process (such as an IE upgrade).
So, how do we avoid rebooting the system while the system is doing “stuff”?
(The GUI avoids this because the desktop is not created until all of the
RunOnce keys have been created, so the user can’t request a shutdown that
way, although Ctl-Alt-Del works, so I guess they could cause the same
trouble manually.)
Unfortunately, our service doesn’t start early enough to stop an auto-login,
and it’s one of the earliest services in the system, so I think that may not
be possible to do.
I did discover that RunOnce processes are executed serially (the second one
does not start until the first has finished), and they are removed as the
processes are started, so I considered monitoring all of the various RunOnce
and RunOnceEx values/keys and waiting until they were empty. But then what
would happen if some RunOnce adds more RunOnce keys? (Is that possible?)
Another idea was to remove any auto-logon info prior to the first boot, and
then restore it when we think it’s safe to do so, but it seems that that
info is only examined on a reboot, or could we somehow force the system to
auto-logon if necessary? (Or is there even a way to programmatically log in
a user from a service?)
I couldn’t come up with a clean/obvious solution to this, and I figured that
if anyone else has run into this, it would be the people on this list…
Suggestions? Am I just missing something obvious?
(Thanks!)