Question:

How to detect whether an old version of you application is already installed and then offer to uninstall it automatically?

Answer:

You can use the Detect Previous Version function to you detect the path of a previously distributed version of your product. If the function succeeds, the %_SB_ERRORCODE% return value is nonzero. The return variable contains the path to the previous version. You can use Run Program to launch the uninstallation program.

Set Variable %_SB_INSTALLDIR% to Detect Previous Version ("{4D910660-BBBC-11D8-6784-02015E7D18BE}")
If %_SB_ERRORCODE% Equals "1" Then
Display Message Box "The installer has detected a previous SB5 installa..." -- "Previous Version Detected"
If %_SB_RETURN% Equals "$IDYES$" Then
Run Program %_SB_INSTALLDIR%\Uninst_[PRODUCTNAME].exe /U "[UNINSTALL_LOG]" (Always Install) [Wait]
End
End


SetupBuilder Requirements:

Developer Edition. This function is not available in the Clarion or Professional versions of the SetupBuilder Installation System.