1
votes

I need to install file in the regular installation folder (i.e. c:\program files\mycompany\myapp) but I also need to copy files into a subfolder located in the windows folder i.e. c:\windows\myfolder.

While I have no problem with the "install" folder, I can't see how to create a sub-folder in c:\windows?

Any ideas?

Thanks.

Thierry

UPDATE:

I probably should have been a bit more precise and provide additional information. This is the xml I have:

<Fragment>
  <Directory Id="TARGETDIR" Name="SourceDir">
    <Directory Id="ProgramFilesFolder">
      <Directory Id="INSTALLFOLDER" Name="MyCompany">
        <Directory Id="ClientFolder" Name="Client">
        </Directory>
        <Directory Id="ServerFolder" Name="Server">
        </Directory>
      </Directory>
    </Directory>
  </Directory>
  <Directory Id="WindowsFolder" Name="WindowsFolder">
    <Directory Id="MyFolder" Name="MyFolder"></Directory>
  </Directory>
</Fragment>

When I try to compile my wix project, I get the following error:

Error 1 : The Directory with Id 'WindowsFolder' is not a valid root directory.  
There may only be a single root directory per product or module and its Id attribute 
value must be 'TARGETDIR' and its Name attribute value must be 'SourceDir'

PS: I'm new to this and I'm reading a book on how to use Wix, but I need this asap, so please be patient with me :). Thank you.

3
You can only have 1 root folder... TARGETDIR. All other folders have to be children. WF should be a sibling of PFF.Christopher Painter
@ChristopherPainter... I've just answered my own question but your comment is exactly what I was missing! Thanks.Thierry

3 Answers

1
votes

You create Directory elements based on System Folder Properties. Specifically the WindowsFolder property. Then create a child Directory element for your folder.

You should have very strong justification before doing this as this is an operating system area. I typically tell developers no unless they have a very, very good reason.

1
votes

The penny dropped!!

You need to add a directory reference directly under

<Directory Id="TARGETDIR" Name="SourceDir">

along with the rest of your directories. You'll end up with something like this

  <Directory Id="ProgramFilesFolder">
    <Directory Id="INSTALLFOLDER" Name="MyApp">
      <Directory Id="ClientFolder" Name="Client"/>
    </Directory>
  </Directory>
  <Directory Id="WindowsFolder">
    <Directory Id="MyFolder" Name="MyFolder"/>
  </Directory>
</Directory>

Where the WindowsFolder will tell the installer to use the "windows" folder and to use the sub folder within it, just set the Directory your ComponentGroup (or other) to MyFolder i.e.

<ComponentGroup Id="MyFolderComponents" Directory="MyFolder">
  ..
  ..
</ComponentGroup>
0
votes

That regular installation folder of yours is based on a tree that will have ProgramFilesFolder somewhere, and then your subfolder name. You do the same for the Windows folder using the standard Windows Installer property:

Windows Folder

which is one of this bunch:

Property Reference