Sunday, April 17, 2011

How to get the installation directory?

The MSI stores the installation directory for the future uninstall tasks.

Using the INSTALLPROPERTY_INSTALLLOCATION property (that is "InstallLocation") works only the installer has set the ARPINSTALLLOCATION property during the installation. But this property is optional and almost nobody uses it.

How could I retrieve the installation directory?

From stackoverflow
  • Use a registry key to keep track of your install directory, that way you can reference it when upgrading and removing the product.

    Using WIX I would create a Component that creates the key, right after the Directy tag of the install directory, declaration

    Michael Damatov : I haven't done it, so I still need to know how get the directory...
    CheGueVerra : What are you using to create the MSI file with, every language would have it's specifications to get that information
    Michael Damatov : I've made it with InstallShield 11.5 (I know it's outdated...). BasicMSI project.
  • I would try to use Installer.OpenProduct(productcode). This opens a session, on which you can then ask for Property("TARGETDIR").

    Michael Damatov : Already tried: doesn't work
  • Try this: var sPath = this.Context.Parameters["assemblypath"].ToString();

  • I'd use MsiGetComponentPath() - you need the ProductId and a ComponentId, but you get the full path to the installed file - just pick one that goes to the location of your installation directory. If you want to get the value of a directory for any random MSI, I do not believe there is an API that lets you do that.

0 comments:

Post a Comment

Note: Only a member of this blog may post a comment.