Archive: Store reboot flag - but where?


Store reboot flag - but where?
Hi,

I want to improve behaviour when reboot on install is required. Therefore I want to store the reboot flag state at the end of installation somewhere.

My application can then read this entry and show the user a warning that he has to reboot first (for example).

But I want that stored reboot state to be removed/changed when the user reboots the machine.

I know of three possibilities:

a) I create a small file which removes the stored reboot flag. This can be called by "RunOnce" registry key.

b) I create a file "has_to_reboot" e.g. in INSTDIR and let Windows delete this file on startup (using mechanism similar to "Delete /Rebootok").

c) I use a kernel mutex. This is not stored to disk at all. Seems this is a more elegant solution.

Currently I tend to use "c)" because it should be even safer than the disk-stored solutions.

Does anyone see a problem using "c)" or has a better idea?


You can call RegCreateKeyEx with the system plugin and use the REG_OPTION_VOLATILE flag


I can't see where is the big deal.
If reboot is mandatory, just skip the finish page and make your installer look like most IS installers.
See the attached example,


Forcing reboot is bad, even with msgbox before. IMHO

As said before I want to _improve_ my installer / user experience. ;-)


I want to _improve_ my installer / user experience.
Ah! forgive me, I wasn't focused to this point of view, I was just focused to the practical side :)
Sounds great user experience!
Forcing reboot is bad, even with msgbox before.
Seems that none told that to IS developers thru past 10 years, in several IS versions!

Re: Store reboot flag - but where?

Originally posted by stb
I want to store the reboot flag state at the end of installation somewhere.

My application can then read this entry and show the user a warning that he has to reboot first (for example).

But I want that stored reboot state to be removed/changed when the user reboots the machine.
I suggest you have the installer write the current boottime to a registry key where you have your other application information stored. (If your application doesn't have any registry info, create a key under HKEY_LOCAL_MACHINE\SOFTWARE\your_company\your_application). Then when your application starts it checks the boottime against that key and (if necessary) alerts the user that they must reboot before running the app. If they have rebooted, you could delete the registry key and won't need to check it again for future executions of your app.

Microsoft says the boottime can be determined by running "net statistics server" (http://support.microsoft.com/kb/555737) and scan the string produced for the line starting "Statistics since". On my system (XP SP2) that value looks like it matches the registry string in HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Prefetcher\StartTime. If that value is good for other versions of Windows, you might be able to read that instead of doing the "nsExec::ExecToStack" with the Net command and parsing through the output.

Don

@demiller9: Thanks for contributing another method. I think it is more error-prone than the other solutions.

IMHO kernel mutex is the best one: It is quite easy to use, has no problem with windows versions, does not store anything to the disk and does use widely used techniques (so MS will less probably disable it or insert bugs into it). The only draw back I can see is the kernel mutex format for Multi processor machines on Win2003 and higher (this "Global\" thing) -- so one has to make a differentiation between old (95) and new (2003) Windows versions. But I'm getting quite theoretical here...

@Red Wine: Sorry for flaming a bit, but IMO InstallShield is no ideal. Not for this reboot thing and not for many other reasons. It may be practical for the developer to make a simple "MsgBox + Reboot" command. The only advantage I can see is: you can be very sure the user reboots before executing the software. But I can see grave disadvantages:

- What about silent installation? Silent reboot? :-(

- Most users do not really read those texts and messages on the screen because we (developers) show to much silly and superfluous texts -- especially in installers. Many people just click on "next" buttons.

- There are some users who do work with their machine. They have documents open and maybe shutdown/reboot their machine very seldom. They like software which can be installed and run directly. They might expect your installer to perform this way. And if a reboot is required they would like to continue working and try the new software later (e.g. next day). Please be aware that there are end users who will lose their work due to "forced" reboots.

Have a look at the WinXp security update: If you install those updates they almost always require a reboot. If you decline to reboot at once the message will minimize to tray. IMHO this is good. Every 15 minutes the message box will popup again. IMHO this is crap. I want to decide for myself when to reboot. It's funny that Microsoft needs multiple weeks, monthes or years to create a patch, and that it takes something like a month to get deployed but when it is on the machine you have to decline rebooting every 15 minutes.

Nevertheless: Thanks for all contributions.


Yeah, after all "do it the way like" is the entire meaning of Nullsoft Scriptable Install System!