+ Reply to Thread
Results 1 to 8 of 8

Thread: Detect Previous Version Installed

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Location
    Livingston, TX
    Posts
    11

    Question Detect Previous Version Installed

    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,

  2. #2
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Detect Previous Version Installed

    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

  3. #3
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Detect Previous Version Installed

    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

  4. #4
    Join Date
    Jan 2011
    Location
    Livingston, TX
    Posts
    11

    Default Re: Detect Previous Version Installed

    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,

  5. #5
    Join Date
    Jan 2011
    Location
    Livingston, TX
    Posts
    11

    Default Re: Detect Previous Version Installed

    Will this work:

    Code:
    [ 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.

  6. #6
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Detect Previous Version Installed

    Yes, this is a very good starting point!

    Friedrich

  7. #7

    Default Re: Detect Previous Version Installed

    >> (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.

  8. #8
    Join Date
    Mar 2004
    Posts
    4,307

    Default Re: Detect Previous Version Installed

    I have posted a demo here:

    http://www.lindersoft.com/forums/sho...0468#post60468



    Friedrich

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts
  •