title: WiX: Setting the install directory from a RegistySearch causes the error "Could not acess network location"
body: <p>I am making an installer based on WixUI_Advanced. I am using the solution from here: <a href="https://stackoverflow.com/questions/5479790">WiX: How to override &quot;C:\Program Files (x86)&quot; on x64 machine in WixUI_Advanced sequence?</a></p>
  
  <p>However, I want the installer to remember the previous install directory. Attempting to set the APPLICATIONFOLDER property results in the error "Could not access network location" followed by the directory name. This only happens when a value is actually found in the registry (when upgrading the program).</p>
  
  <p>Here is the relevant code:</p>
  
  <pre><code>&lt;Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="OronDF343" UpgradeCode="22187c5e-5fd6-4734-802e-236abd321433"&gt;
      &lt;Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="$(var.ProductName)" /&gt;
  
  &lt;PropertyRef Id="NETFRAMEWORK45" /&gt;
  &lt;Condition Message="This application requires .NET Framework 4.5.1 or later. Please install .NET Framework version 4.5.1 or higher and then run this installer again."&gt;
    &lt;![CDATA[Installed OR (NETFRAMEWORK45 &gt;= "#378758")]]&gt;
  &lt;/Condition&gt;
  
      &lt;MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of $(var.GlobalProductName) is already installed." /&gt;
  
  &lt;!-- This is where the problem is. This is how it was implemented in the solution linked above, but I have tried it without the SetDirectory. --&gt;
  &lt;Property Id="APPLICATIONFOLDER" Secure="yes"&gt;
    &lt;RegistrySearch Id="RegistrySearch" Type="raw" Root="HKLM" Win64="$(var.Win64)" Key="Software\$(var.Company)\$(var.ProgID)" Name="InstallLocation" /&gt;
  &lt;/Property&gt;
  &lt;SetDirectory Id="APPLICATIONFOLDER" Value="[$(var.PlatformProgramFilesFolder)]$(var.GlobalProductName)"&gt;APPLICATIONFOLDER=""&lt;/SetDirectory&gt;
  &lt;!----&gt;
  
      &lt;MediaTemplate EmbedCab="yes" /&gt;
  
  &lt;Directory Id="TARGETDIR" Name="SourceDir"&gt;
    &lt;Directory Id="DesktopFolder" Name="Desktop" /&gt;
    &lt;Directory Id="$(var.PlatformProgramFilesFolder)"&gt;
      &lt;Directory Id="APPLICATIONFOLDER" Name="$(var.GlobalProductName)"&gt;
        &lt;Directory Id="skins" Name="skins"/&gt;
      &lt;/Directory&gt;
    &lt;/Directory&gt;
    &lt;Directory Id="ProgramMenuFolder"&gt;
      &lt;Directory Id="ApplicationProgramsFolder" Name="$(var.GlobalProductName)"/&gt;
    &lt;/Directory&gt;
  &lt;/Directory&gt;
  
  &lt;Property Id="ApplicationFolderName" Value="$(var.GlobalProductName)" /&gt;
  &lt;Property Id="WixAppFolder" Value="WixPerMachineFolder" /&gt;
  &lt;WixVariable Id="WixUISupportPerUser" Value="0" /&gt;
  &lt;WixVariable Id="WixUILicenseRtf" Value="gpl-3.0.rtf" /&gt;
  &lt;Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.GlobalProductName)" /&gt;
  &lt;Property Id="WixShellExecTarget" Value="[#$(var.Project.TargetFileName)]" /&gt;
  &lt;CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" /&gt;
  
      &lt;Feature Id="ProductFeature" Title="$(var.ProductName) Core Files" Level="1" Absent="disallow"&gt;
    &lt;ComponentRef Id="CreateDirectories" /&gt;
          &lt;ComponentGroupRef Id="ProductComponents" /&gt;
    &lt;ComponentGroupRef Id="RegistryStuff" /&gt;
      &lt;/Feature&gt;
  &lt;UI&gt;
    &lt;UIRef Id="WixUI_Advanced" /&gt;
    &lt;Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication"&gt;WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed&lt;/Publish&gt;
  &lt;/UI&gt;
  &lt;!--Hacks for WixUI_Advanced install folder--&gt;
  &lt;CustomAction Id="OverwriteWixSetDefaultPerMachineFolder" Property="WixPerMachineFolder" Value="[APPLICATIONFOLDER]" Execute="immediate" /&gt;
  &lt;CustomAction Id="SetARPINSTALLLOCATION" Property="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" /&gt;
  &lt;InstallUISequence&gt;
    &lt;Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" /&gt;
  &lt;/InstallUISequence&gt;
  &lt;InstallExecuteSequence&gt;
    &lt;Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" /&gt;
    &lt;Custom Action="SetARPINSTALLLOCATION" After="InstallValidate"/&gt;
  &lt;/InstallExecuteSequence&gt;
  &lt;/Product&gt;
  </code></pre>
  
  <p>EDIT: I didn't include the code which saves the registry value but it was being saved as '"[APPLICATIONFOLDER]"' and removing the double quotes fixed it for a fresh install.
  Also forgot brackets in the SetDirectory</p>