How to create subfolder in C:\ProgramData and deploy configuration files into that folder?
Asked Answered
E

2

12

I tried this using the following code but the subfolder inside the "ProgramData" folder is not created. My requirement is to install some files in install directory provided by user and deploy a few configuration files into "ProgramData", e.g. C:\ProgramData\COMPANYNAME\APPNAME.

Find the code I use below. Can anyone help me to identify the issue? Or another solution to achieve this?

 <Fragment>
    <Directory Id="TARGETDIR" Name="SourceDir">
      <Directory Id="ProgramFilesFolder">
        <Directory Id="INSTALLFOLDER" Name="APPNAME" />
      </Directory>

      <Directory Id="CommonAppDataFolder">
        <Directory Id="CommonAppDataManufacturerFolder" Name="COMPANYNAME">
          <Directory Id="MyAppDataFolder" Name="APPNAME">
          </Directory>
        </Directory>
      </Directory>
    </Directory>
  </Fragment>
Estimation answered 9/6, 2016 at 12:55 Comment(0)
B
11

You need a feature containing a component installing into the MyAppDataFolder directory for the installer to implicitly create the folder during installation. With no component installing there the folder won't be created.

Just defining a Directory structure is not good enough to get those folders to be created.

Barolet answered 9/6, 2016 at 15:24 Comment(2)
How can I create an empty directory when there are no files/subdirectories during installation, but only later (E.g log files generated when application starts)Sealed
@swaechter, you can do this using a CreateFolder element. Example below.Graph
G
3

It's not required to copy files into the folder to create the folder. You just need specify the element.

For instance..

  <Fragment>
    <Component Id="FolderComponent" Directory="BackupFolder" Guid="GUID" Win64="yes">
      <CreateFolder />
    </Component>
  </Fragment>
Graph answered 3/6, 2021 at 13:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.