How do I set the TARGETDIR programtaically?

I am creating an MSI package for my application. The requirement is such that if application A is installed at client machine, this new set up should install in that application folder. Otherwise it should create its own folder.

I have created custom installer. I have overridden the methods like OnInstall, OnBeforeInstall, etc. But no effect on TARGETDIR.

Even though I write this :

this.Context.Parameters["TARGETDIR"] = new_path;

It still installs it to old path which is set as DefaultLocation property of ApplicationFolder Tab of setup project.

Does anyone know how to resolve this?


Can't be done in a VS setup project because all custom actions run after the install has (almost) finished, so it's too late to change the install folder. VS setup projects have no support for running CAs early to do this.

You may be able to do this with a search if the registry path for that other app is in a registry item.

  1. In launch conditions, Search Target Machine, add a registry search for that registry item and it will go into an uppercase property name, it defaults to REGISTRYVALUE1, something like that.

  2. In File System view, right click file system on target machine and add special folder, custom folder. Make the default location [TARGETDIR] (it should be that by default) and make the Property that registry property name, that REGISTRYVALUE1.

  3. Your files go in that custom folder.

If that works, the files will go to the default target directory in program files unless that path is there, and then they should go in there. However, there's a dialog for users to choose the install folder so I don't know what you plan to do about that.

Need Your Help

I am getting error message during Android plugin in Eclipse

android eclipse eclipse-plugin

An error occurred while collecting items to be installed