Problem
I have an MSI that creates and starts a Windows service during installation and stops and removes the service during uninstallation. This works fine when installing and uninstalling by itself, but when upgrading, the Files in Use dialog is displayed (only on Vista and later due to the new Restart Manager), indicating that the service is in use.
Background
The Files in Use dialog is displayed during the InstallExecute sequence by the InstallValidate custom action, which is scheduled immediately before the RemoveExistingProducts custom action; this means that the previous version has not been uninstalled yet, so the Files in Use dialog should be shown.
The MSDN documentation indicates that the RemoveExistingProducts action must be scheduled after the InstallValidate action, and I currently have the RemoveExistingProducts actions scheduled immediately after the InstallValidate action.
Potential Solution
I would like to reschedule the RemoveExistingProducts custom action to immediately before the InstallValidate custom action so that the previous installation has a chance to stop and remove the service before the Files in Use dialog is shown. I tried rescheduling the actions, and it appears to work correctly with no adverse side-effects (although the log still indicates that the InstallValidate action executes before the RemoveExistingProducts action), but I'm hesitant to use this solution since it violates the MSDN documentation, and there may be adverse effects that I'm just not seeing yet.
Has anyone tried this? The only other alternative I can think of is to have the new installation stop the service of the old installation, but this is undesirable because it requires the installation to have information about all old installations that it can upgrade (stopping this particular service may involve more than just a simple call to the Service Manager to stop it).