2
votes

How would I install files directly into a pre-existing folder on the user's computer? All documentation I read only explains creating a custom INSTALLDIR.

Eg. c:\ProgramFiles(x86)\ExampleFolderA\ExampleFolderB\InstalledFile.exe

1

1 Answers

5
votes

You should first define the directory structure:

<Directory Id="TARGETDIR" Name="SourceDir">
  <Directory Id="ProgramFilesFolder">
    <Directory Id="ExampleFolderAId" Name="ExampleFolderA">
      <Directory Id="ExampleFolderBId" Name="ExampleFolderB" />
    </Directory>
  </Directory>
</Directory>

Note that the definition above does NOT create directories when the installation runs. In order for the directories to be actually "created" you have to either place files there (using Component elements), or explicitly state that the directory is empty.

Something like this:

<DirectoryRef Id="ExampleFolderAId">
  <Component Id="SampleComponent" Guid="GUID-GOES-HERE">
    <File Id="SampleFile" Source="C:\readme.txt" KeyPath="yes" />
  </Component>
</DirectoryRef>

or

<DirectoryRef Id="ExampleFolderBId">
  <Component Id="EmptyFolderComponent" Guid="GUID-GOES-HERE">
    <CreateFolder />
  </Component>
</DirectoryRef>

Hope you get the idea.