- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Update INI file on MODIFY
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Update INI file on MODIFY
Hi,
I installed my application with some features choosing out of CustomSetup dialog. The selected features will be saved as Properties in an INI file:
setup.ini
[install]
feature1=1
feature2=1
feature3=0
Now the user should be able to MODIFY the installed features by updateing the INI file like ...
lected features will be saved as Properties in an INI file:
setup.ini
[install]
feature1=0
feature2=0
feature3=1
How I can this be done? Right now the setup.ini will be written perfectly on first install, but wont be updated on MODIFY.
Thanks for some hints.
br
thomas
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
I too was surprised to find that MODIFY mode couldn't be used to modify INI file in a Basic MSI project. I created a support case on this issue last year. The reason I was told that the INI variables were not modified is because the associated component was already installed. INI variables and also registry key values associated with a given component are only written when the component is being installed in that execution of the installer. This of course as you have discovered is problematic and non-intuitive. When you run in MODIFY mode one of the things one would logically expect to be able to modify is the INI variables and/or registry key values. The solution I came up with was to do the write to the INI file explicitly in a deferred action in system mode using WriteProfString() function. This has to be done as a deferred action in system mode because WriteProfString() requires Admin rights the UI phase does not run as Administrator. This further complicates writing INI variables stored in PROPERTY values as all properties are lost in deferred actions running in system mode. To pass property values to the deferred custom action you need to use CustomActionData. Search the reference manual for how to do this.
The next problem is that the INI values displayed in MODIFY mode in your setup dialog are not the current settings from the INI file but come from the original default property values defined in the Basic MSI file. This means when a user runs MODIFY all the settings default to their original defaults defined in the MSI not to the currently defined settings from the INI file. The solution to this is I created a custom action LoadOptionDefaultsFromIniFile() that runs at the beginning of the UI that reads the current values from the INI file and loads them into their associated PROPERTY values. Also to support silent mode also ran this function at start of Execute phase since UI custom actions are skipped in silent mode.
In my case I also wanted to be able to pass these configuration variables on the command line to support silent mode and that added even more to the complexity as there was no simple way to tell if a PROPERTY value was set from the command line or from the Basic MSI default property value. My solution here was to create a duplicate of every PROPERTY value with the name <property>_DEFAULT. So for example there would be COMPORT property and a COMPORT_DEFAULT property. In the Basic MSI project COMPORT_DEFAULT would be set the the desired default value for COMPORT and the COMPORT property would be set to "_DEFAULT". Then I created a custom action SetAllOptionDefaults() which checked each property and if for example COMPORT contained "_DEFAULT" then the actual default value was copied to COMPORT from COMPORT_DEFAULT. This complexity was necessary to allow PROPERTIES specified on the command line to override current values defined in the INI or PROPERTY defaults defined in the Basic MSI project itself. The LoadOptionDefaultsFromIniFile() knows to only load into PROPERTIES that still contain "_DEFAULT" thus not overwriting command line PROPERTY settings.
All this took a considerable amount of time to get working but MODIFY mode now works as one would intuitively expect. That is it brings up a setup dialog with all the current settings read from the INI file but including any overrides specified on the command line. And then it allows user to make modifications in the setup dialog and then finally updates the INI file will all the currently displayed settings (PROPERTIES) in the setup dialog.
I should mention that I had another installer that used registry keys to store configurations and had similar issues and used the same mechanism to get MODIFY mode to work intuitively in that case. Just use the registry read/write functions instead of Read and WriteProfString() functions.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
Hi,
thanks for your comment.
At the moment I want to checkout another method to reach updating the INI file. I determined that during that writing INI file can be avoided by setting an condition - and I used this because the INI file was written, but with the default values.What I want is to read out the values from the INI file to reuse this and to overwriting the default values.
The INI file should be read out by SystemSearch by looking for a key word in a section of INI file. But right now I think it does not work correctly , although it should be working. Unfortunately the MSI log does not help - it is hard to read and find the correct information.
br
thomas