Using a user-defined property for file search - Advanced Installer Community
t3knoid
Posts: 21
Joined: Wed May 27, 2015 8:15 pm

Using a user-defined property for file search

I want to use a property for the path setting in the Directory Properties of a file search. The property is set using a registry search. I cannot get this to work. The property is getting set however, when I reference it in the path field of the Directory Properties, it is empty. Essentially what I am doing is determining the installation folder of Microsoft Office. Take that value (path) and use it to determine if the file MSCAL.OCX exists. Here's the gist of what I've done:

1. Use appsearch to set a property using a registry location (e.g. [OFFICE_2010_PATH]).
2. Use the [OFFICE_2010_PATH] property as the path in the File Search to find mscal.ocx (e.g. OFFICE_2010_PATH_MSCAL_OCX).

If I use a built-in property such as [ProgramFilesFolder] as the path value, the search for mscal.ocx works fine.

Here's a sample log entry. Notice that OFFICE_2010_PATH_MSCAL_OCX is getting enumerated first. From what I understand with APPSEARCH, the order should not matter.
AppSearch: Property: OFFICE_2010_PATH_MSCAL_OCX, Signature: FileSearchSign_2_2
MSI (c) (88:D0) [10:34:57:484]: Note: 1: 2262 2: CompLocator 3: -2147287038
MSI (c) (88:D0) [10:34:57:484]: Note: 1: 2262 2: IniLocator 3: -2147287038
MSI (c) (88:D0) [10:34:57:484]: Note: 1: 1322 2:
MSI (c) (88:D0) [10:34:57:484]: Note: 1: 1322 2:
MSI (c) (88:D0) [10:34:59:691]: Note: 1: 2363 2: C:\System Volume Information\
MSI (c) (88:D0) [10:34:59:691]: Error while attempting to search in/ below folder: System Volume Information
MSI (c) (88:D0) [10:35:04:013]: Note: 1: 2363 2: E:\System Volume Information\
MSI (c) (88:D0) [10:35:04:013]: Error while attempting to search in/ below folder: System Volume Information

...
...

AppSearch: Property: OFFICE_2010_PATH, Signature: Office14Sign
MSI (c) (88:D0) [10:35:04:038]: Note: 1: 2262 2: CompLocator 3: -2147287038
MSI (c) (88:D0) [10:35:04:038]: PROPERTY CHANGE: Adding OFFICE_2010_PATH property. Its value is 'C:\Program Files (x86)\Microsoft Office\Office14\'.
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Using a user-defined property for file search

Not sure if this helps, but...

I tested your logic, and it seemed to work for me (I used misc.exe instead of mscal.ocx):
MSI (c) (FC:8C) [09:29:39:796]: Doing action: AppSearch
Action 9:29:39: AppSearch. Searching for installed applications
Action start 9:29:39: AppSearch.
AppSearch: Property: OFFICE_2010_PATH, Signature: AppSearchSign
MSI (c) (FC:8C) [09:29:39:798]: PROPERTY CHANGE: Adding OFFICE_2010_PATH property. Its value is 'C:\Program Files (x86)\Microsoft Office\Office14\'.
AppSearch: Property: MISC, Signature: FileSearchSign
MSI (c) (FC:8C) [09:29:39:799]: PROPERTY CHANGE: Adding MISC property. Its value is 'C:\Program Files (x86)\Microsoft Office\Office14\misc.exe'.
Action ended 9:29:39: AppSearch. Return value 1.
Maybe order does matter? I added my registry search first, then I added the file search.
Search.PNG
Search.PNG (7.24 KiB) Viewed 8326 times

Thanks.
t3knoid
Posts: 21
Joined: Wed May 27, 2015 8:15 pm

Re: Using a user-defined property for file search

Thanks for verifying. I've performed more research on this and according to the following MSDN article:

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

"The AppSearch action searches for file signatures using the CompLocator table first, the RegLocator table next, then the IniLocator table, and finally the DrLocator table."

That tells me order should not matter. The RegLocator is evaluated first so the property that is set using a registry value should get its value first. However, when I look at the log, the property that is getting set using a signature from the DrLocator table is getting evaluated first. I looked at the MSI using Orca and the tables look right.

AppSearch Table
4-18-2017 12-38-52 PM.png
4-18-2017 12-38-52 PM.png (3.32 KiB) Viewed 8325 times
RegLocator Table
4-18-2017 12-38-18 PM.png
4-18-2017 12-38-18 PM.png (1.79 KiB) Viewed 8325 times
DrLocator Table
4-18-2017 12-39-30 PM.png
4-18-2017 12-39-30 PM.png (1.44 KiB) Viewed 8325 times
I am going to try an empty project.
t3knoid
Posts: 21
Joined: Wed May 27, 2015 8:15 pm

Re: Using a user-defined property for file search

I tried this with an empty project and it worked fine. :(
t3knoid
Posts: 21
Joined: Wed May 27, 2015 8:15 pm

Re: Using a user-defined property for file search

I've ran more tests. It's definitely looking like the order in which the property is on the AppSearch table determines its enumeration. For example, here's the MSI that is generated for my installer:
4-18-2017 2-05-24 PM.png
4-18-2017 2-05-24 PM.png (11.59 KiB) Viewed 8321 times
The log entries for each property enumeration shows exactly in the order shown above.
codesynergy
Posts: 100
Joined: Fri Nov 14, 2014 10:29 pm

Re: Using a user-defined property for file search

"The AppSearch action searches for file signatures using the CompLocator table first, the RegLocator table next, then the IniLocator table, and finally the DrLocator table."

That tells me order should not matter...
I have the same interpretation of that statement.

In my test project, I deleted the registry search and re-added it. This forced the registry search to happen after the file search. So, it does appear the order matters. It looks like you have a lot of searches, and it would be a pain to re-add them. I wonder if you can re-order them using the Table Editor in Advanced Installer?
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Using a user-defined property for file search

Hello,

Unfortunately you cannot reorder the searches using "Table Editor" view. The order in which they are inserted in "AppSearch" table (I can confirm you this is the searches order execution) is the order in which you have created them in our "Search" page, not the alphabetical order we currently display them in "Search" page. This is a limitation of Advanced Installer. We'll try to add predefined support to edit the search order in a future version of our application. As soon as this feature will be available we will update this thread.

We hesitate to add this feature in AI because the Windows Installer documentation is not very consistent regarding searches order. However, according to our tests over the time we can confirm that that the searches order order is the order they are included in the "AppSearch" table at build time.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Building Installers”