5

I have an MSI file that is installing a folder with a bunch of files inside it. I have a location that I am putting the files in:

Windows XP: C:\Documents and Settings\All Users\Documents\MyFolder

Windows 7: C:\Users\Public\Documents\MyFolder

The issue is that I do not want to hardcode these paths, but no matter where I look I cannot find out how to do this, because everywhere I look they are talking about making shortcuts for all users and that is not what I am trying to do. How can one install a folder to an "All Users" location?

Something like this:

<PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS" />

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="WIX_DIR_COMMON_DOCUMENTS">
    <Directory Id="MyFolder" Name="MyFolder">
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Jimmy
  • 941
  • 2
  • 8
  • 27

1 Answers1

8

Windows Installer does not have a property for that folder, but a WiX-provided custom action does.

Per the documentation on the OSInfo custom actions:

  1. Reference the WixUtilExtension extension for the linker.
  2. Define the property via a reference:

    <PropertyRef Id="WIX_DIR_COMMON_DOCUMENTS" />
    

Then, define the directory somewhere under the TARGETDIR directory. For example:

    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="WIX_DIR_COMMON_DOCUMENTS">`
        <Directory Id="MyFolder" Name="MyFolder" />`
      </Directory>`
    </Directory>`
Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
Tom Blodget
  • 20,260
  • 3
  • 39
  • 72
  • I changed my question to reflect the changes I made, but now I get 2600 errors (no exaggeration). It says something about "Since this folder is not rooted in a standard directory, this component does not fit the criteria" – Jimmy Jul 01 '13 at 18:14
  • 1
    Yes, you (or heat.exe) have to generate GUIDs for your components. WiX serves us well by eliminating GUIDs when it can but it can't always do it. If you always do only MajorUpgrades (recommended) then the GUIDs don't matter. Otherwise, component GUIDs must be the same from version to version. – Tom Blodget Jul 01 '13 at 18:36
  • So I am using the following heat command, does this not auto-gen GUIDS? "C:\Program Files\WiX Toolset v3.7\bin\heat.exe" dir "..\..\MyFolder\Stuff" -dr INSTALLFOLDER -gg -var var.MyFolderBin -srd -ag -sfrag -t ..\..\template.xslt -out ..\..\MyFolderBin.wxs – Jimmy Jul 01 '13 at 19:10
  • 1
    So removing the -ag fixed the issue, I overlooked that I was using this tag when running heat.... thank you once again for helping me with my WiX experience! – Jimmy Jul 01 '13 at 19:58