Installing to C:\ProductName
Some applications need to be installed to C:\ProductName
or something similar, but 99.9% (if not 100%) of the examples in the net install to C:\Program Files\CompanyName\ProductName
.
The following code can be used to set the TARGETDIR
property to the root of the C:
drive (taken from the WiX-users list):
<CustomAction Id="AssignTargetDir" Property="TARGETDIR" Value="C:\" Execute="firstSequence" />
<InstallUISequence>
<Custom Action="AssignTargetDir" Before="CostInitialize">TARGETDIR=""</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="AssignTargetDir" Before="CostInitialize">TARGETDIR=""</Custom>
</InstallExecuteSequence>
NOTE: By default, TARGETDIR
does not point to C:\
! It rather points to ROOTDRIVE
which in turn points to the root of the drive with the most free space (see here) - and this is not necessarily the C:
drive. There might be another hard drive, partition, or USB drive!
Then, somewhere below your <Product ...>
tag, you need the following directory tags as usual:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="APPLICATIONFOLDER" Name="$(var.ProductName)">
<!-- your content goes here... -->
</Directory>
</Directory>