KoenT
Posts: 13
Joined: Mon May 18, 2009 8:30 pm

Avoid overwrite if user changed file

Hi,

I have the following situation:
- the installer installs program files in the normal program files location, and then also some data files in a folder chosen by the user (usually just C:\MyAppData)
- one of the files in the data files is a settings file (MySetting.txt) that users will edit according to their needs (the file has no version info)

Now, what we would like to obtain for this settings file is the following:
- if upon installation the file does not exist, then the installer should install it
- if upon installation the file does exist:
. if the user has changed it, don't overwrite it
. if the user has not changed it, overwrite it during install
How would I do that with AI 6.9.1?

Another somewhat related question: what happens in general with files that don't have version info, like bitmap files? How can one make sure that existing ones are always overwritten by the ones from the installer?

Thanks,
Koen
Cosmin
Posts: 5797
Joined: Tue Jul 10, 2007 6:39 pm
Contact: Website

Re: Avoid overwrite if user changed file

Hi Koen,

Unfortunately Windows Installer does not support this directly.

To detect the file you can try using a search. The property of this search can be used to condition some custom actions which backup the file before install and restore it after install. For more information please see the Preserve File on Install how-to. This way the file can be preserved if it already exists on the machine.
what happens in general with files that don't have version info, like bitmap files?
For an upgrade process, the older version is completely uninstalled before the new version is installed. So the old files are removed. For a normal installation which overwrites existing files, Windows Installer uses the file versioning rules.
How can one make sure that existing ones are always overwritten by the ones from the installer?
For this you can use the "Ensure that this file overwrites any installed target file" option in the Version tab of the "Edit File" dialog.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
KoenT
Posts: 13
Joined: Mon May 18, 2009 8:30 pm

Re: Avoid overwrite if user changed file

OK! Works! Thank you for the fast and effective help!
Koen

Return to “Common Problems”