resuming an upgrade after reboot
This isn't a Wise-specific problem, but I'm in the "fearful" stage so looking for advice and ideas please (or maybe just reassurance ;-)
I have a Windows Installer MSI package that installs drivers which sometimes require a restart before they can be upgraded; the drivers are installed by a deferred custom action after WriteRegistryValues. When a reboot IS needed there's a rollback and the user is told to reboot and run the install again.
In the InstallExecuteSequence the RemoveExistingProducts action is between InstallValidate and InstallInitialize, so when an upgrade signals that it needs a restart, the previous package has been removed. So when a reboot's needed, after the rollback and the error message saying "reboot and re-run this" our software is no longer installed. If the user reboots and repeats the install things work fine.
I need to automate rebooting and resuming the install, so the user doesn't have to actually do anything (apart from agreeing to the restart of course - and in silent mode they won't even need to do that.)
A command written into the registry's RunOnce key can run the install again after the reboot, but I'm thinking it will be tricky to condition ForceReboot on what happens in the deferred custom action that does the driver install. Also maybe tricky to decide what to do in the resumed install.
Any thought on this will be much appreciated.
Comments
I can only generalise, but the runonce technique is certainly a good starting point. What you also need to do is to analyse what sort of information your "second" install pass is going to need, and ensure that this information is saved somewhere like the registry by the 'first' install pass.
So the logic goes something like this:
Installer runs
Installer checks to see if there are registry keys to indicate that the "second pass" install logic needs to run.
If registry keys not present, run 'first pass' logic and write regkeys, then reboot.
Else run "second pass" logic, clean up registry keys and exit.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Thanks for the thoughts, Ed.
Today the bit that's got me puzzled is how to implement the ForceReboot, because the need for the reboot is only going to be known inside the deferred CA. Since it's deferred the CA can't provide a condition for a ForceReboot action in InstallExecuteSequence. Hmm ... perhaps tomorrow's morning shower will help inspiration. (Or more likely there's an obvious way that I'm not seeing yet.)
Did the shower help? Not sure I totally understand what you are trying to achieve, but you don't have to rely on the reboot support in the MSI - the alternative is to call SHUTDOWN.EXE with the appropriate command line switches to force a reboot if required. Shutdown.exe is present in all recent windows operating systems and can do either a full shutdown or a reboot, and you can build in a delay countdown in case you want to give users time to save data. By calling an EXE on the destination system, you can also code for conditions based on previous events.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Oh, good idea, thanks! That might be the way to go. I hadn't thought of calling Shutdown. (I was in too much rush to take a shower this morning (probably just as well my cube-neighbors are out sick!))
Fwiw Shutdown.exe is not present in Windows 2000 (at least, I couldn't find shutdown.exe as a file), but I don't think we'll be supporting pre-XP with this product.
So far my plan is:
CA calls DLL to install driver; if driver requires restart the DLL will write RunOnce then exec Shutdown; after restart the MSI is run again (from the start, conditioning things on RESUME). I'll have to detect whether the initial part of the install is running in silent mode, when not silent ask the user if they want to shutdown but if silent then set the RunOnce command to do a silent install.
I won't get to do prototyping for a few weeks, but better start reading up ... at what stage after reboot does RunOnce happen? I think the resume of the install will have to be after login, because the installer has to be run with admin privilege. Could be messy if there's a non-admin login. Maybe there's some neat way to enforce admin-only after the restart.
Sorry, just thinking out loud here -- I appreciate your help!
Shutdown.exe is available in the windows 2000 resource kit, so if you have to support W2K you could always include the file in your initial install.
RunOnce is present in both HKLM and HKCU; I believe the HKLM entry runs prior to login, but of course the HKCU entry runs after login - so it's your choice where you place the entry. If using HKCU in an environment with roaming profiles, you may need to consider checking if the logon is at the same machine as before.
The UILevel property value will tell you whether an app is running in silent mode or not - check it out in MSI.CHM if you've not used it before.
Check whether you actually need to perform a reboot after installing the driver - it may be possible to start a service programmatically rather than relying on a reboot, and this would make the install so much simpler to implement.
With non-admin user accounts, you could use RUNAS as a way of getting the app to run elevated, or you could use the AT scheduler to re-run the install after a reboot - this would run the install in the system context, so as long as you didn't need access to the network or the user profile, you could still perform an elevated install. All in all, lots of ways to be tricky, but the best strategy is to try and avoid the reboot in the first place.
If your issue has been solved, please use the "Mark as Solution" link on the most relevant thread.
Again thanks for all the ideas. Unfortunately we can't always avoid a reboot - Windows networking being what it is, things get in a locked state and only after a restart can the driver be installed. I just know there are hidden pitfalls but making this work will be a background job for the next couple of months, so hopefully the wrinkles will gradually get ironed out.
Would you like to reply?
Login or Register to post your comment.