views:

641

answers:

4

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?

+2  A: 

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

CheGueVerra
I haven't done it, so I still need to know how get the directory...
Michael Damatov
What are you using to create the MSI file with, every language would have it's specifications to get that information
CheGueVerra
I've made it with InstallShield 11.5 (I know it's outdated...). BasicMSI project.
Michael Damatov
A: 

I would try to use Installer.OpenProduct(productcode). This opens a session, on which you can then ask for Property("TARGETDIR").

Martin v. Löwis
Already tried: doesn't work
Michael Damatov
A: 

Try this: var sPath = this.Context.Parameters["assemblypath"].ToString();

A: 

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.

Steven Bone