mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

How do I install user specific folders?

Hello,

Like many other users of Advancd Installer, I wish to copy some user-specific files placed next to the MSI. The process outlined in the user guide documentation on installing a user specific file using File Copy/Move works well but does not address the case where the user-specific file is in a subdirectory (or the subdirectory itself is what needs to be copied).

With some searching, I turned up a similar post requesting help with this and cosmin's advice here and here. But it's not clear if anyone got it working.

As for me, when I follow cosmin's instructions, AI actually creates a directory in the Installation Application Folder literally named SOURCEDIR and places the subdirectory within it! Not exactly what I had hoped for.

Has anyone been able to copy entire directories successfully using File Copy/Move?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How do I install user specific folders?

Hello,

This is a little bit tricky. Let us store the path to your folder in a property called XMLSOURCE. What you need to do is follow these steps
- on "Install Parameters" page set XMLSOURCE to "C:\"
- on "Files and Folders" page add a new Property Based Folder. Select XMLSOURCE as the property from the dialog that pops up.
- from the directory tree select the folder in which you want the contents of the XMLSOURCE folder to be installed. For our purpose let's just select "Application Folder"
- add a new "File Operation->File copy/move". On the "Edit File Copy/Move" dialog, make the following settings:

Code: Select all

Source File
  Name : *
  Folder: XMLSOURCE
Destination File
  Name: <leave blank>
  Folder: <leave this as is>
Properties:
  Component: <select the component which should contain the file operation>
  Operation: Copy
- on the "Custom Actions" page, under "InstallUISequence->Begin" add a new "Property Set with Formatted" with the following settings:

Code: Select all

Property Name: XMLSOURCE
Formatted Text: [SOURCEDIR]xml
Replace 'xml' with the path to the folder in which your files reside. Attached is an example project that implements this.

Regards,
Gabriel
Attachments
PropertyBasedSubfolder.zip
(2.98 KiB) Downloaded 448 times
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: How do I install user specific folders?

Hi Gabriel, thanks for your help. Your method works well. Do you know if it's possible to have File Copy/Move overwrite a pre-existing file? My installer contains a default file which I'd like to overwrite with a user-specific custom file using File Copy/Move.

Thanks
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How do I install user specific folders?

Hello,

The File Copy/Move operation uses the File Versioning Rules to determine whether a file should be overwritten or not. Unfortunately there is no way to make it overwrite a file regardless of these rules. Nonetheless it shouldn't be too hard to make sure your files follow them, since a newly modified file will have a higher Date then the already installed one thus overwriting it.

If this is not a viable solution, the only alternative is using a Custom Action to make sure files are overwritten regardless of the file versioning rules.
Also note that files/folders installed using a File Copy/Move operation will not be automatically removed upon uninstallation of your product since they do not belong to any Component, which is why you should use a File Removal operation to remove them when uninstalling.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/
mchristianson
Posts: 19
Joined: Sat Jan 10, 2009 1:43 am
Location: Phoenix, USA
Contact: Website

Re: How do I install user specific folders?

Hi again, thanks for your continuing help.

I tried your idea of the replacement files with newer dates, but it did not work. Would you be able to create a working example?
GabrielBarbu
Posts: 2146
Joined: Thu Jul 09, 2009 11:24 am
Contact: Website

Re: How do I install user specific folders?

Hello,

As MSDN states, if a file's modified date is greater than the creation date, the file will not be overwritten. The only way to overwrite such a file is to overwrite it with a versioned file (with a greater version, if both files are versioned). Here is the relevant quote from MSDN:
If the Modified date is later than the Create date for the file on the computer, do not install the file because user customizations would be deleted. If the Modified and Create dates are the same, install the file. If the Create date is later than the Modified date, the file is considered unmodified, install the file.
Since text files do not support versioning, I am afraid your only choice is to use a custom action to ensure they overwrite any existing files.

Regards,
Gabriel
Gabriel Barbu
Advanced Installer Team
http://www.advancedinstaller.com/

Return to “Common Problems”