SiriusDG
Posts: 4
Joined: Wed May 21, 2008 5:44 pm

Adding Keys to Existing INI Files

When I add a feature to my application, and then add keys to the MyAppSettings.ini file to support that feature, rather than add the keys to the current file, the installer replaces the entire ini file with the new one, thereby destroying all of the end users current settings. This can (and has) caused massive data loss to my clients, as the ini file tracks where project elements are store on their hard drives.

The ini file is being handled as a Windows Installer file, not a plain text file.

I am not creating updaters, every new build gets a complete installer, but the ini files should not overwrite existing data -- however, I cannot find a way to flag that specifically, am I missing something?

This worked fine in my previous install maker application, I hope there is a way to make it work here as well, this is very critical path for me.

Thank you.

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

Re: Adding Keys to Existing INI Files

Hi,

You are encountering this behavior because you are using the automated upgrade feature. Basically, when you perform an upgrade, the old package is uninstalled (the old INI is removed) and the new package is installed (the new INI is installed). Note that this is the way a major upgrade is performed by Windows Installer.

The solution in your case is to set the "Permanent" attribute for the component of the INI entries. This can be done in the Compoent Properties pane in the Organization page. If this attribute is set, the component of the INI entries will not be removed when an uninstall is performed.

Since your package must remove the INI file when an uninstall is performed, you can use a custom action like explained in the Remove a file or a folder during installation how-to. Please note that this custom action should use the condition:

Code: Select all

(REMOVE="ALL" AND (NOT UPGRADINGPRODUCTCODE))
in order to run only during an uninstall which is not performed by an upgrade.

Regards,
Cosmin
Cosmin Pirvu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”