My requirement is to create a directory in programdata/test/example. How can I do that in wix?
Asked
Active
Viewed 4.9k times
3 Answers
73
Define the folder like this:
<Directory Id="TARGETDIR" Name="SourceDir">
<Directory Id="CommonAppDataFolder">
<Directory Id="TestFolder" Name="test">
<Directory Id="ExampleFolder" Name="example" />
</Directory>
</Directory>
</Directory>
The important part here is the CommonAppDataFolder
Id, which is known by Windows installer. You can find the full list of known system folders in the Windows Installer Property Reference.
If you install any files to that folder, it will be created implicitly. If not, you can force it to be created by installing a component like this:
<Component Id="CreateTestFolder" Directory="ExampleFolder" Guid="PUT-RANDOM-GUID-HERE">
<CreateFolder />
</Component>

Wim Coenen
- 66,094
- 13
- 157
- 251
-
I get this error when using it: `error CNDL0205: The Directory with Id 'CommonAppDataFolder' is not a valid root directory. ` (plus a bit more about only having a single root directory per product). What am I doing wrong? – noelicus Aug 18 '14 at 12:06
-
@noelicus: in windows installer, the top-level parent directory must always be TARGETDIR. I'll update my answer to clarify this. – Wim Coenen Oct 07 '14 at 15:04
-
@WimCoenen Is it possible to copy folder/files1..to..files5 during the installation of wix installer. – Royal Nov 19 '14 at 12:45
-
@Royal: comments are not the right place to ask new questions. Just post a new stackoverflow question. – Wim Coenen Nov 19 '14 at 13:28
-
@WimCoenen I have raised the new SO question please help me http://stackoverflow.com/questions/27020130/how-to-copy-folder-files1-to-files5-during-the-installation-of-wix-installer – Royal Nov 19 '14 at 15:09
17
Under <Product>
you can enter:
<DirectoryRef Id="TARGETDIR">
<Directory Id="CommonAppDataFolder">
<Directory Id="CommonAppXXXX" Name="test">
<Directory Id="CommonAppYYYY" Name="example">
<Component Id="CreateProgramDataZZZ" Guid="ABC-ETC">
<CreateFolder />
</Component>
</Directory>
</Directory>
</Directory>
</DirectoryRef>
And reference the component CreateProgramDataZZZ
in your feature
.
It can also be helpful to set permissions on the directory like this:
<CreateFolder>
<util:PermissionEx User="Users" GenericAll="yes" />
</CreateFolder>
(in place of <CreateFolder />
)

noelicus
- 14,468
- 3
- 92
- 111
-
-
use the WIX_ACCOUNT_USERS on User=, as the account will change on other languages. – LeoPucciBr Feb 13 '18 at 13:35
1
this will create folder for you...
<Directory Id="DIR_ID" Name="DIR_NAME">
<Component Guid="GUID" Id="id" KeyPath="no" NeverOverwrite="no" Permanent="no" Location="local">
<CreateFolder>
<util:PermissionEx CreateChild="yes" CreateFile="yes" Delete="yes" Read="yes" ReadAttributes="yes" ReadExtendedAttributes="yes" ReadPermission="yes" Traverse="yes" GenericRead="yes" GenericWrite="yes" User="Everyone" />
</CreateFolder>
</Component>
</Directory>

naive pro-grammar
- 330
- 4
- 10