Bug in installation to Program Files directory

Sep 8, 2016 at 10:59 AM
Hi, Oleg!
I have an installer with managedUI.
During the installation I selected installation folder in standard InstallDir dialog:
C:\Program Files\My Company\My Product

Product is installed to C:\Program Files (x86)\My Company\My Product

In Load event handler
InstallDir=C:\Program Files\My Company\My Product
In BeforeInstall event handler
InstallDir=C:\Program Files (x86)\My Company\My Product

What happened?
Sep 9, 2016 at 2:58 AM
Edited Sep 9, 2016 at 5:58 AM
No it is not a bug. It is an unfortunate non-intuitive behavior of MSI. I guess MSI handles special folder ProgramFiles in a tricky way and always maps path C:\Program Files to the actual folder specific to your MSI platform, which is in your case C:\Program Files (x86).

In my experiment I tried to eliminate Wix# from the experiment and used the following WiX code:
<?xml version="1.0" encoding="Windows-1252"?>
<Wix xmlns="http://schemas.microsoft.com/wix/2006/wi">
  <Product Id="e2e75b4b-666c-4ae3-8957-4d29c85dc0d9" Name="CustomActionTest" Language="1033" Codepage="Windows-1252" Version="" UpgradeCode="e2e75b4b-666c-4ae3-8957-4d29b85dc0d8" Manufacturer="Oleg">
    <Package InstallerVersion="200" Compressed="yes" SummaryCodepage="Windows-1252" Languages="1033" />
    <Media Id="1" Cabinet="CustomActionTest.cab" EmbedCab="yes" />

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder" Name="ProgramFilesFolder">
        <Directory Id="INSTALLDIR" Name="Test">

          <Component Id="Component.readme.txt" Guid="e2e75b4b-666c-4ae3-8957-4d295c7e7230">
            <File Id="readme.txt" Source="readme.txt" />


    <UIRef Id="WixUI_InstallDir" />

    <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR" />

    <Feature Id="Complete" Title="Complete" Absent="allow" Level="1">
      <ComponentRef Id="Component.readme.txt" />

//Corresponding Wix# code
var project = new Project("CustomActionTest",
                  new Dir(@"%ProgramFiles%\Test",
                      new File("readme.txt"));

project.UI = WUI.WixUI_InstallDir;
And it behaves the same way as in your experiment.
After changing the install dir to C:\Program Files the product is still installed to C:\Program Files(86).
If you are trying to install to x64 then you need to use project.Platform = Platform.x64.