windows-installerinstallshieldinstallscript

How can I find the previous install location of an application in InstallScript during a major upgrade?


I'm updating an installer written with InstallShield to perform a major upgrade of an application and have InstallScript functions invoked by custom actions to back up and restore some files from the application's directory. I have the script working with previous installation directory hardcoded but need to find the actual location that the application was installed.

I can get the location of current install using:

MsiGetProductInfo(PRODUCT_GUID, INSTALLPROPERTY_INSTALLLOCATION, savedInstallDir, bufferSize);

but if I change PRODUCT_GUID to the hardcoded value of the product code of the previous installation then I get an empty string in savedInstallDir:

MsiGetProductInfo("{my-previous-product-code}", INSTALLPROPERTY_INSTALLLOCATION, savedInstallDir, bufferSize);

Solution

  • Are you sure the installation location has been persisted for the older version that is installed? Do you get anything when you try from VBScript (update with your own product GUID of course):

    Dim installer : Set installer = CreateObject("WindowsInstaller.Installer")
    MsgBox installer.ProductInfo("{9B061D60-4E2C-4987-BFFD-423E3D477660}","InstallLocation")
    

    I checked all my installed packages and only about a dozen or so (out of a few hundred packages) had this path persisted. Script to check all installed packages.


    In the registry: look for the value "InstallLocation" under location:

    GUIDS: