PDA

View Full Version : Detect Previous Version Installed



crmfghtr
12-05-2011, 09:37 AM
Hello,
If you have already compiled a newer version of your softwae, and you do not have the older GUID code how would you detect an older version and uninstall the program including any files/folders created since the install?

Thanks,

linder
12-05-2011, 09:52 AM
Robert,

If you do not have the Product GUID but you have registered your uninstall application with Windows, what you can do is to enumerate the all keys in the Windows Uninstall registry key (e.g. using the "Get Registry SubKey..." script function) to try to detect your previous version.

The uninstall key is located at:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Curr entVersion\Uninstall

The (displayed) name of the product can be found in the "DisplayName" value.

If detected, read the uninstall .exe location from the registry (e.g. using the "Get Registry Key Value..." script function) and execute the uninstall application (e.g. using the "Run Command Line..." script function).

The uninstall commands are stored in the "UninstallString" value.

Does this help?

If you can't use the above "method", let me know how you would do it without SetupBuilder (e.g. search all available hard-drives for a specific file name) and then I can tell you how to convert it to SetupScript.

Friedrich

linder
12-05-2011, 09:56 AM
BTW, to remove files and folders created AFTER the installation, you have to compile a "custom uninstall" (see "Creating a Custom Uninstall" in the manual).

Of course, you can also handle this directly from your installer, e.g. using the "Delete File(s)...", "Delete Foilder Tree...", etc. script functions.

Friedrich

crmfghtr
12-05-2011, 03:01 PM
I think at this point, it would be easier to search for the .exe name on the users computer. If found then I could run a un-install. In addition I could then delete all the folders/files associated with the older version. I tried to copy "Detect Previous Application B" into my setup, but I was unable to do so. I wanted to use this script and call it before the install runs on the new version.
I know you can include scripts I just can't figure out how to include them.

thanks,

crmfghtr
12-05-2011, 04:02 PM
Will this work:


[ Initialize Setup ]
! --- Define commonly used constants ---
#include script "Common Definitions.sbi"
! Important: Initialize default install folder and program group variables
Set Variable %COMPANY% to "MyCompany"
Set Variable %APPTITLE% to "MyProduct"
! BEGIN: Detect Previous Version --------------------
Set Variable %PREVIOUS_VERSION_DETECTED% to "$FALSE$"
Set Variable %PREVIOUS_VERSION_NUMBER% to "1.0.4.0"
Set Variable %PREVIOUS_PATH% to ""

! Detect an older version of MyProduct
Set Variable %APPTITLE% to FUNCTION:Search For File("MyProduct.exe", 4) in "MyProduct.exe" [Return List]
If %_SB_ERRORCODE% Does Not Equal (Ignore Case) "0" Then
Set Variable %PREVIOUS_VERSION_DETECTED% to "$TRUE$"
Set Variable %_SB_INSTALLDIR% to "%PREVIOUS_PATH%"
Set Variable %PREVIOUS_VERSION_NUMBER% to "%_SB_RETURNEX%"
Display Message Box "This installer has successfully detected a previou..." -- "Previous Version Detected"
Run Program %PREVIOUS_PATH%\MyProduct.exe %PREVIOUS_PATH%\Uninst_MyProduct.exe (Always Install) [Wait]

! Will this delete all the files with the extension
Delete Files "%PREVIOUS_PATH%\Backup\*.txt"
Delete Folder "%PREVIOUS_PATH%\Backup"

End

If there is no older version detected or when the older version is detected and un-installed then I want to start the installation of the new version at the end of this script.

Chris
12-05-2011, 06:42 PM
>> (e.g. search all available hard-drives for a specific file name) and then I can tell you how to convert it to SetupScript.

That is exactly what I need to do :-) So please explain how.

linder
12-06-2011, 02:51 AM
I have posted a demo here:

http://www.lindersoft.com/forums/showthread.php?p=60468#post60468

;)

Friedrich

linder
12-06-2011, 02:55 AM
Yes, this is a very good starting point!

Friedrich