Search code examples
wixwindows-installer

Wix v3 Setting Install Folder according Property given in command line


I would like to change the installation location according to condition.
If property DRIVE was provided in the installation command line, I would like to perform :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="INSTALLFOLDERA" Name="My Program Files">
      <Directory Id="KUKU" Name="KUKU"  >
         <Directory Id="INSTALLFOLDER" Name="BuiltInPropertiesExample"/>
    </Directory>
  </Directory>
</Directory>

If property DRIVE was NOT provided (in the installation command line), I would like to perform :

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
          <Directory Id="INSTALLFOLDER" Name="BuiltInPropertiesExample"/>
  </Directory>
</Directory>

How do I perform such installation ?


Solution

  • I found solution to my problem:

    <Directory Id="TARGETDIR" Name="SourceDir">
            <Directory Id="ProgramFilesFolder">
              <Directory Id="INSTALLFOLDER" Name="BuiltInPropertiesExample" />
        </Directory>
    </Directory>
    
    <SetDirectory Id="INSTALLFOLDER" Value="[LOCATION]" Sequence="execute" >
      <![CDATA[NOT Installed OR LOCATION]]>
    </SetDirectory >
    

    when executing

    msiexec /i BuiltInPropertiesExample.msi  LOCATION=D:\MyProduct\ 
    

    the tool is installed D:\MyProduct\

    When executing

    msiexec /i BuiltInPropertiesExample.msi
    

    the tool is installed C:\Program Files\