PDA

View Full Version : Uninstall previous version.



mikedoris
09-16-2009, 04:30 AM
Hi,

We use the following code to uninstall any other version of our product which is on the system :

! Remove any previous installation silently.
Set Variable %_SB_INSTALLDIR% to FUNCTION:Detect Previous Version("{5F62ECB0-443D-11DD-6784-0002EE1F18BE}")
If %_SB_ERRORCODE% Does Not Equal "0" Then
/* Display Message Box "The installer has detected a previous version of t..." -- "Previous version detected." */
Run Program %_SB_INSTALLDIR%\Uninst_[PRODUCTNAME].exe /U "[UNINSTALL_LOG]" /S (Always Install) [Wait]
If %_SB_ERRORCODE% Does Not Equal "0" Then
Display Message Box "Failed to uninstall previous version." -- "Failed to uninstall previous version."
Exit Installation(1)
End
End

The issue we have is that if any of the files are locked the user is asked if they would like to reboot at the end of the uninstall. The issue with this is that if the user chooses to reboot it occurs immediately and on reboot they are left without any installation at all.

What I need to happen is that the user isn't told that they need to reboot until install phase is complete. Is this possible?

Thanks,

Mike Doris

linder
09-16-2009, 04:44 AM
Mike,

By default, if an uninstall detects a locked (in-use) file, it needs a reboot to finish the uninstall process.

What you can try is the following (it's in theory, I did not test it). Write a custom uninstall that can detect a command line option (e.g. /NR stands for Never Reboot or /DNR stands for Do Not Reboot or whatever). If your installer passes this command line option to the uninstall application, set the $SB_RESTARTFLAG$ Installer Flag to 0 to avoid a reboot.

You call it with something like this from your installer:
Uninst_[PRODUCTNAME].exe /U "[UNINSTALL_LOG]" /S /DNR

Note: You can use the "Get System Info(Command Line)" function to retrieve the command line parameters and then "Handle String Operation (InStr)" function to check if the command line includes /NR or /DNR or whatever. Then use "Set Installer Flag" to disable the reboot process.

Does this help?

Friedrich