I wrote this for ClickThrough a long time ago. Solution from that looks a lot like this (You provide a Property called "ApplicationFolderName"):
<Property Id="A" Secure="yes" />
<DirectoryRef Id="TARGETDIR">
<Directory Id="ApplicationFolder" Name="App" />
</DirectoryRef>
<Condition Message="Must specify TARGETDIR property when doing an administrative install.">Installed OR (ACTION="ADMIN" AND TARGETDIR<>"")</Condition>
<CustomAction Id="TARGETDIRtoA" Property="A" Value="[TARGETDIR]" Execute="firstSequence" />
<CustomAction Id="SpecifiedA" Property="ApplicationFolder" Value="[A]" Execute="immediate" />
<CustomAction Id="PerMachineInstall" Property="ApplicationFolder" Value="[ProgramFilesFolder]\[ApplicationFolderName]" Execute="immediate" />
<CustomAction Id="PerUserInstall" Property="ApplicationFolder" Value="[LocalAppDataFolder]\Apps\[ApplicationFolderName]" Execute="immediate" />
<InstallUISequence>
<Custom Action="SpecifiedA" Before="LaunchConditions">NOT Installed</Custom>
</InstallUISequence>
<InstallExecuteSequence>
<Custom Action="PerMachineInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS=1 OR (ALLUSERS=2 AND Privileged))</Custom>
<Custom Action="PerUserInstall" Before="CostFinalize">NOT Installed AND ACTION="INSTALL" AND A="" AND (ALLUSERS="" OR (ALLUSERS=2 AND (NOT Privileged))</Custom>
</InstallExecuteSequence>
Program Files (x86)
based on a condition in the SetProperty element that does the overriding like this:<SetProperty Id="ProgramFiles64Folder" Value="[ProgramFilesFolder]" Before="CostInitialize">
– Earleanearleen