elou
Posts: 96
Joined: Tue Apr 14, 2015 9:12 am

Read Ini-File from Parameterisable location

Hello,
I need to read the value from an ini file before the installation begins and set this value to an installer property.
The location of the ini file is defined by another property.

For example:

Code: Select all

PROPERTY_PATH_TO_DATA_INI=C:\Data
The value from PROPERTY_PATH_TO_DATA_INI may be default, given as parameter or extracted from a registry value
in C:\Data the [a.ini] should exists and look like this:

Code: Select all

[Application]
pathToData=C:\data
The string "C:\data" should be set in a property for future use. Some files will be installed in that directory.

Can I achieve that in the Application Search? Which is the best way to achieve that?

Regards, Éric
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Read Ini-File from Parameterisable location

Hello Eric,

Yes, what you want to do is achievable. You will have to create a ".INI Search" which will have as path either a property set in "Install Parameters" or the path returned by a "Registry Search". Here we will have two different scenarios:

Scenario 1:

1) First, we have to create a property and set its value to our desired value. This can be done by going to "Install Parameters" page, click on the "New Property" button from the toolbar and insert your desired "Name" and "Value" (e.g. Name: MY_PATH and Value: C:\)

2) Now we have to create the search. For this, you can go to "Search" page, click on the "New search" button from the toolbar. Please keep in mind that the name of the search will also be the name of the property which will store the search result. After creating the search, right click on it --> "Add Search Location" --> "INI". The "Type" should be of "Retrieve the raw value from INI file" and the folder should be the name of the property earlier defined at step 1). (e.g. MY_PATH).

Scenario 2:

1) Since we want to get the path from a registry key, we now have to first define a "Registry Search" (Example of the property which will store the registry search value: MY_REG_SEARCH. This can be done by going to "Search" page --> click on "New Search" button from the toolbar --> right click on the search --> "Add Search Location" --> "Registry".

2) Now we have to create the "INI Search" which is done based on our earlier defined "Registry Search". To do this, you can repeat the step 2) from the first Scenario (Scenario 1), but in the "Folder" field, insert the name of the "Registry Search" (in our example, we called it MY_REG_SEARCH)

3) The last step and the most important here is to change the "INI Search" execution time to be higher than the "AppSearch" execution time, because, by default, the "INI Search" (the search based on the registry search) is done before the "AppSearch" (the action where the registry search is done). In order to achieve this, we can use the "Table Editor" page. Now go to "Table Editor" page --> click on "InstallUISequence" --> search for "AI_AiIniLocator" and set its value to be higher than "100" (which is the value of "AppSearch") and lower than "200" (for example, you can set it to "120").

Now, please repeat the step number 3), but this time go to "InstallExecuteSequence". We are mainly doing this in case you will ever need your setup to run silently. The step number 3) will only affect the installers launched with Full UI.

Also, please keep in mind that "Table Editor" feature is available starting with an "Enterprise" license or above.

Please let me know if this helps!

Kind regards,
Catalin
Catalin Gheorghe - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”