title: Wix Conditionally Install Component if Registry Key Exists
body: <p>I have a component I need to install only if a registry key exists which means an application has been installed.</p>
  
  <p>I need to assign the value of the registry key (it is a directory) to a property then use this property to copy files from.</p>
  
  <p>I have the following script so far but get an error "The system cannot find the file '[MYTESTDIR]fileToCopy.dat'."</p>
  
  <p>Any help would really be appreciated.</p>
  
  <pre><code>&lt;Property Id="MYTESTDIR"&gt;
      &lt;RegistrySearch Id="NetFramework20"
              Root="HKLM"
              Key="SOFTWARE\TEST\VALUE\1.00"
              Name="MyName"
              Type="directory" /&gt;
  &lt;/Property&gt;
  
  &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
      &lt;Directory Id="ProgramFilesFolder"&gt;
          &lt;Directory Id="TEST" Name="Test"&gt;       
              &lt;Component Id="MyComponent" Guid="E5FF53DE-1739-42c4-BE37-60F810C9CD69"&gt;
                &lt;Condition&gt;MYTESTDIR&lt;/Condition&gt;
                &lt;File Id="fileToCopy.dat" Name="fileToCopy.dat" Source="[MYTESTDIR]fileToCopy.dat"&gt;
                    &lt;CopyFile Id="fileToCopy.datCopy" DestinationProperty="WEBSERVICEBINFOLDER" /&gt;
                &lt;/File&gt;
  
          &lt;/Directory&gt;            
      &lt;/Directory&gt;
  &lt;/Directory&gt;
  
  &lt;Feature Id="MyFeature" Title="MyFeature" Level="1"&gt;
      &lt;ComponentRef Id="MyComponent" /&gt;
  &lt;/Feature&gt;
  </code></pre>