0

I am making an installer based on WixUI_Advanced. I am using the solution from here: WiX: How to override "C:\Program Files (x86)" on x64 machine in WixUI_Advanced sequence?

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).

Here is the relevant code:

<Product Id="*" Name="$(var.ProductName)" Language="1033" Version="$(var.Version)" Manufacturer="OronDF343" UpgradeCode="22187c5e-5fd6-4734-802e-236abd321433">
    <Package InstallerVersion="200" Compressed="yes" InstallScope="perMachine" Description="$(var.ProductName)" />

<PropertyRef Id="NETFRAMEWORK45" />
<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.">
  <![CDATA[Installed OR (NETFRAMEWORK45 >= "#378758")]]>
</Condition>

    <MajorUpgrade AllowSameVersionUpgrades="yes" DowngradeErrorMessage="A newer version of $(var.GlobalProductName) is already installed." />

<!-- 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. -->
<Property Id="APPLICATIONFOLDER" Secure="yes">
  <RegistrySearch Id="RegistrySearch" Type="raw" Root="HKLM" Win64="$(var.Win64)" Key="Software\$(var.Company)\$(var.ProgID)" Name="InstallLocation" />
</Property>
<SetDirectory Id="APPLICATIONFOLDER" Value="[$(var.PlatformProgramFilesFolder)]$(var.GlobalProductName)">APPLICATIONFOLDER=""</SetDirectory>
<!---->

    <MediaTemplate EmbedCab="yes" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="DesktopFolder" Name="Desktop" />
  <Directory Id="$(var.PlatformProgramFilesFolder)">
    <Directory Id="APPLICATIONFOLDER" Name="$(var.GlobalProductName)">
      <Directory Id="skins" Name="skins"/>
    </Directory>
  </Directory>
  <Directory Id="ProgramMenuFolder">
    <Directory Id="ApplicationProgramsFolder" Name="$(var.GlobalProductName)"/>
  </Directory>
</Directory>

<Property Id="ApplicationFolderName" Value="$(var.GlobalProductName)" />
<Property Id="WixAppFolder" Value="WixPerMachineFolder" />
<WixVariable Id="WixUISupportPerUser" Value="0" />
<WixVariable Id="WixUILicenseRtf" Value="gpl-3.0.rtf" />
<Property Id="WIXUI_EXITDIALOGOPTIONALCHECKBOXTEXT" Value="Launch $(var.GlobalProductName)" />
<Property Id="WixShellExecTarget" Value="[#$(var.Project.TargetFileName)]" />
<CustomAction Id="LaunchApplication" BinaryKey="WixCA" DllEntry="WixShellExec" Impersonate="yes" />

    <Feature Id="ProductFeature" Title="$(var.ProductName) Core Files" Level="1" Absent="disallow">
  <ComponentRef Id="CreateDirectories" />
        <ComponentGroupRef Id="ProductComponents" />
  <ComponentGroupRef Id="RegistryStuff" />
    </Feature>
<UI>
  <UIRef Id="WixUI_Advanced" />
  <Publish Dialog="ExitDialog" Control="Finish" Event="DoAction" Value="LaunchApplication">WIXUI_EXITDIALOGOPTIONALCHECKBOX = 1 and NOT Installed</Publish>
</UI>
<!--Hacks for WixUI_Advanced install folder-->
<CustomAction Id="OverwriteWixSetDefaultPerMachineFolder" Property="WixPerMachineFolder" Value="[APPLICATIONFOLDER]" Execute="immediate" />
<CustomAction Id="SetARPINSTALLLOCATION" Property="ARPINSTALLLOCATION" Value="[APPLICATIONFOLDER]" />
<InstallUISequence>
  <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
</InstallUISequence>
<InstallExecuteSequence>
  <Custom Action="OverwriteWixSetDefaultPerMachineFolder" After="WixSetDefaultPerMachineFolder" />
  <Custom Action="SetARPINSTALLLOCATION" After="InstallValidate"/>
</InstallExecuteSequence>
</Product>

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

Community
  • 1
  • 1
OronDF343
  • 528
  • 1
  • 3
  • 14
  • I'd create a verbose log and see what the actual property value is. You get that message when the result doesn't look like a drive letter path so it tries it as a network path and it fails. – PhilDW Feb 22 '15 at 20:53
  • In the error message it says "Could not access network location" followed by the correct path. Does that not mean the property is set to that? – OronDF343 Feb 22 '15 at 21:06
  • I was curious about the actual path, and if your setup is 32-bit and trying to do something to a native 64-bit folder. I don't know what part of that link has the solution you're using, but you will have difficulty trying to defeat the rule about trying to install from a 32-bit setup into a 64-bit location. Only 64-bit MSIs can install 64-bit components to 64-bit locations like the native program files directory https://msdn.microsoft.com/en-us/library/aa367451(v=vs.85).aspx – PhilDW Feb 23 '15 at 18:23
  • I am installing a 64-bit package on a 64-bit OS. – OronDF343 Feb 23 '15 at 18:50
  • It looks like a verbose log is needed, install with a command line that includes /l*vx and let's see it if there's no clear cause of what're getting. – PhilDW Feb 23 '15 at 20:03
  • Examining the log led to a discovery: The value from the registry has quotes, while the original value did not have quotes! Also, the SetDirectory needed brackets to get the correct value. – OronDF343 Feb 23 '15 at 21:27

0 Answers0