Hi,
This would be possible with the "ForceReboot" Standard Action, which Advanced Installer does not currently support. However, I have tried adding it manually (with Orca) in the "InstallExecuteSequence" table and everything worked exactly as you described, with one exception: after the reboot, the new version package is not found and thus the installation cannot be resumed. Moreover, if you try to install another MSI package, Windows Installer will perform a rollback of the previously uninstalled program since its installation was not completed. I shall investigate this issue further and let you know if I find a solution.
The second possible approach would be to create a Custom Action that behaves similarly to the "ForceReboot" Standard Action, but this is a (fairly) complex task. This Custom Action, in its simplest form, would be a VBScript that uses WMI (in order to reboot the computer). Please let me know if you want to use this approach and I will create a script that performs this task.
Therefore I shall describe the approach you have already mentioned: simply inform the user that he needs to uninstall the previous version of the program and then abort the installation process. These are the required steps:
1. Create a new text file ("PrevVersionFound.vbs") and copy the following code into it:
Code: Select all
Function PrevVersionFound()
ShowMsg("Uninstall the previous version first")
PrevVersionFound = 3
Exit Function
End Function
Function ShowMsg(strPrompt)
Const msiMessageTypeUser = &H03000000
Set record = Session.Installer.CreateRecord(0)
record.StringData(0) = strPrompt
Session.Message(msiMessageTypeUser + vbExclamation), record
End Function
2. Make sure that the "FindRelatedProducts" Standard Action is visible under both sequences ("InstallUISequence" and "InstallExecuteSequence").
3. Add a "New Attached Custom Action" on
one of the "FindRelatedProducts" stages and select the file you have created previously. Set the following properties for this CA:
- Function Name: PrevVersionFound
- Execution Properties: "Synchronous Execution, check return code"
- Scheduling Options: "Execute only once if present in both sequence tables"
- Execution Condition: OLDPRODUCTS
4. Drag this Custom Action to the "FindRelatedProducts" stage from the other sequence table by holding down the SHIFT key. Make sure that it has the
same properties as above (Execution Condition etc).
Although this Custom Action appears twice, it will be executed only once (if the package installs with UI, the CA from the "InstallUISequence" will be executed).
Hope this helps.
Regards,
Denis