Ok, so here is a final, tested and fully working solution, which also
takes into account a previously installed version, so in case of an
upgrade the already installed location is used by default. The steps
below are in the order of execution, figured out from the msi logs.
All of this is under a Bundle tag:
-----------------------------
        <!-- 1st, the variable is set, containing the
[ProgramFilesLocation] pattern only,
         but [ProgramFilesLocation] is not resolved at this point. -->
        <Variable Name='InstallFolder'
           Type="string"
           Value='[ProgramFilesLocation]\YourCompany' />

        <!-- 2nd, we find out if there is already an installation, and
where it is. (You have
              to create this registry entry from your MSI. I assume
you can do that.) If this
              RegistrySearch changes the above pattern it means that
no further steps are
              needed to be taken into account, as the string is final,
no variable will be
              substituted later, as the string does not contain any []
variables. -->
        <util:RegistrySearch Id="RegistrySearchPreviousInstall1"
            Root="HKLM"
            Key="Software\YourCompany"
            Value="InstallLocationYourCompany"
            Variable="InstallFolderPreviousInstall"/>
        <util:RegistrySearch Id="RegistrySearchPreviousInstall2"
            Root="HKLM"
            Key="Software\YourCompany"
            Condition="InstallFolderPreviousInstall"
            After="RegistrySearchPreviousInstall1"
            Value="InstallLocationYourCompany"
            Variable="InstallFolder"/>

        <!-- 3rd, RegistrySearch finds the location of the 32bit
ProgramFiles folder in the registry -->
        <util:RegistrySearch Id="RegistrySearch64"
            Root="HKLM"
            Key="SOFTWARE\Microsoft\Windows\CurrentVersion"
            After="RegistrySearchPreviousInstall2"
            Value="ProgramFilesDir (x86)"
            Variable="ProgramFilesLocation"/>
        <util:RegistrySearch Id="RegistrySearch32"
            Root="HKLM"
            Key="SOFTWARE\Microsoft\Windows\CurrentVersion"
            Condition="Not ProgramFilesLocation"
            After="RegistrySearch64"
            Value="ProgramFilesDir"
            Variable="ProgramFilesLocation"/>

        <!-- 4th - the Variable value only gets evaluated after all the above
operations
              are done. If there was no previous installation found,
then [ProgramFilesLocation]
              will resolve properly into a string in the variable
InstallFolder.-->

        <!-- 5th, you need to pass InstallFolder as an MsiProperty with your
package: -->
        <Fragment>
                <PackageGroup Id="YourProgramName">
                        <MsiPackage Id="YourProgramName" Compressed="no"
                        Name="YourProgramName.msi" Cache="no"

SourceFile="c:\some\where\over\the\rainbow\YourProgramName.msi">
                                <MsiProperty 
Name='INSTALLLOCATION_MANUFACTURER' Value='[InstallFolder]' />
                        </MsiPackage>
                </PackageGroup>
        </Fragment>

        <!-- 6th, I leave it to your imagination how to handle this in your 
MSI. -->
-----------------------------
Peter

------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/
_______________________________________________
WiX-users mailing list
WiX-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wix-users

Reply via email to