This post provides a tutorial for specifying installation to a partition such as D:\, as opposed to the default installation drive of C:\. 

 

 

Note

 

 

This will also work on mapped network drives. 

 

 

Caution

 

 

You will receive an error if your user does not have the network drive mapped or the partition on their computer.  You may want to use a custom action to determine the location of the partition or to ensure that the network drive is mapped.  For the purposes of demonstration, I am going to hard code the properties.

 

 

Often times, people refer to ROOTDRIVE when attempting to accomplish this particular task.  At most times, this is not an option.  Look at the following example.

 

 

INSTALLDIR = C:\Program Files\Test\

 

 

In the Directory table, it would contain an entry as follows:

 

 

INSTALLDIR  |  ProgramFilesFolder  |  Test

 

 

ProgramFilesFolder appears as follows:

 

 

ProgramFilesFolder  |  TARGETDIR  |  .:Program Files

 

 

If you set ROOTDRIVE equal to D:\ in this case, INSTALLDIR will still resolve to C:\Program Files\Test\.  The reason is the System Folders property group (msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/system_folder_properties.asp).  The ProgramFilesFolder entry will be resolved by Windows Installer to the defined Shell Folder on the system, regardless of what you have defined for the ROOTDRIVE.

 

 

In order to define the drive I would like to install to, I am going to create a property called D_DRIVE with the definition of D:\.  You can create this property in the Property table or on the Product Tab in the Setup Editor of the Windows Installer Editor.

 

 

My Property table entry would appear as follows:

 

 

D_DRIVE  |  D:\

 

 

Now we need to instruct Windows Installer to use this property.  In order to do this, we are going to create an entry in the Directory table as follows:

 

 

D_DRIVE  |  {NULL}  |  D_DRIVE

 

 

Note 

 

 

Do not actually type “{NULL}” in to the Directory table, just leave that particular column of the entry blank.

 

 

Now at this point, in order to tell the installation to install to the D:\ drive, you would change the parent of INSTALLDIR to D_DRIVE as follows:

 

 

INSTALLDIR  |  D_DRIVE  |  Test

 

 

 

 

Caution 

 

 

I would not change the parent of ProgramFilesFolder to D_DRIVE.  It is a best practice to leave the Shell Folder entries as they are.  If you would like to install to D:\Program Files\AppName, then it is a best practice to create an entry into the Directory for your D:\Program Files as well, such as follows:

 

 

D_PFILES_FOLDER  |  D_DRIVE  |  PROGRA~2|Program Files

 

 

INSTALLDIR  |  D_PFILES_FOLDER  |  Test

 

 

Now, all of the components with the directory assignment of INSTALLDIR will be installed to either of the following, depending on the logic used from the above examples:

 

 

D:\Test\

 

 

D:\Program Files\Test\