Showing results for 
Show  only  | Search instead for 
Did you mean: 
Level 7

Installing component parallel to the INSTALLDIR


I have basic MSI project
Is there a way I can set up components to be installed in parallel to the INSTALLDIR ?
So in case the user choose to install under C:\COMPANY\MAIN ( which is the INSTALLDIR ),
several components will be installed under DIR2, like this
Labels (1)
0 Kudos
3 Replies
Level 6

For each component you also have "Destination" field.
Therefore, just type there the wanted location - in your case "C:\COMPANY\DIR2" instead of [INSTALLDIR]
If you dont want the components to have hard coded destination, then define your INSTALLDIR as : C:\COMPANY and then in the component destination field put
This way you can install different components to different destination regarding to your INSTALLDIR
0 Kudos
Level 7

I guess I wasn't clear enough
the C:\COMPANY\MAIN was just an example it could be anything only the DIR2 folder is fixed.

To accomplish what I want I have a CA that get the parent of the INSTALLDIR
and using MsiSetTargetPath set the directory path to the components I need to install n parallel to INSTALLDIR
This work well but I wonder if there is a better way
0 Kudos
Level 7

I don't how/if this would work in a Basic MSI project, but this is how I get it to work in InstallScript MSI. It takes the value of INSTALLDIR, clips off the last folder and replaces it with "MyFeature":

1) Set the Feature/Component Destinations for the feature(s) you want in "C:\COMPANY\DIR2" to a directory identifier called INSTALLDIR_MYFEATURE with some fake value (ex ##INSTALLDIR_MYFEATURE_FAKE##)

2) After Dlg_SdAskDestPath is called (where the user determines where they want your program installed), call this custom function by passing it the regular INSTALLDIR string:

prototype STRING MyFeature_GetMyFeatureInstallDir( byval STRING );	// szInstallDir

function STRING MyFeature_GetMyFeatureInstallDir( szInstallDir )
LIST lstInstallDir;
STRING svMyFeatureInstallDir, svPathPart;

lstInstallDir = ListCreate( STRINGLIST );
// determine what value INSTALLDIR_MYFEATURE should have:
StrGetTokens( lstInstallDir, szInstallDir, "\\" );
svMyFeatureInstallDir = "";
for i = 0 to ListCount( lstInstallDir ) - 2
ListSetIndex( lstInstallDir, i );
ListCurrentString( lstInstallDir, svPathPart );
if svMyFeatureInstallDir != "" then
svMyFeatureInstallDir = svMyFeatureInstallDir + "\\" + svPathPart;
svMyFeatureInstallDir = svPathPart;
svMyFeatureInstallDir = svMyFeatureInstallDir ^ "MyFeature";
MsiSetProperty( ISMSI_HANDLE, "INSTALLDIR_MYFEATURE", svMyFeatureInstallDir );
return svMyFeatureInstallDir;


3) the following line from that function is what sets the correct value for the Feature/Component destinations:
    MsiSetProperty( ISMSI_HANDLE, "INSTALLDIR_MYFEATURE", svMyFeatureInstallDir );

Again, I don't work with Basic MSI projects but hopefully this will give you an idea of how it can be done.

0 Kudos