hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Install a component only if a registry entry exists

Thu Nov 24, 2022 10:49 am

Hi,
I have the following task: A DLL that is part of an installation package comes from a merge module. It should be installed only if a certain registry entry exists. The installer has no selection tree in its GUI, so users cannot interactively (un)select this DLL, and choice is made by the installer itself.
What I did so far:
  • I created a component and placed the merge module in this component.
  • I created a custom search for the registry entry.
  • I failed at adding this custom search to the custom actions because the AI GUI doesn't present the custom search in the "Custom Actions" page. However, I guess I must somehow tell the installer when to execute the search?!
Finally, I don't know how to define the result of the custom search as the condition for installing the component.

Thank you for helping me!
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Install a component only if a registry entry exists

Thu Nov 24, 2022 5:19 pm

Hello Hans,

That should be quite easy to achieve.

Basically, the result of your search is stored in a Windows Installer property. The name of the property is the name of the search (the default name would be "RESULT_PROPERTY").

Now, a property has two states:

- it has a value and therefore it exists

- it has no value and therefore it does not exist

so, depending on your scenario:

1. we need to condition based on the value of the property. In this case, say we do a registry search and the registry entry may have different values depending on the customers machines. We'd like to install the component only when a specific value exists.

Consider we have the following key: HKLM:\SOFTWARE\Test and the following value: test

Let's say "test" can have a value of: "123", "456", "789" and that you would like to install the component only when value "456" is present.

In that case, our condition would look like this:

Code: Select all

RESULT_PROPERTY="456"
simple as that.

2. in the second scenraio, we have again a registry entry, but this time it always have the same value so we don't really care about that.

In this case, we can simply narrow down the condition to: if the registry entry exists, then install the component, otherwise no

The condition would now look like this:

Code: Select all

RESULT_PROPERTY
The opposite of that (say we want to install the component only when the search fails) would be:

Code: Select all

NOT RESULT_PROPERTY
Hope this helps!

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

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Install a component only if a registry entry exists

Fri Nov 25, 2022 11:38 am

Hello Catalin,

Thank you for helping me (once again)! The question which I could not answer so far is, where do I enter the condition? I searched AI up and down for a field named "condition" that was connected to the feature but with no success.

Is the custom search executed when the installer starts up? If not, how to ensure that is has been executed when the result is needed?

The second scenario matches my use case. I don't care about the value of the registry entry, the criterion is whether or not it exists.

Best
Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Install a component only if a registry entry exists

Fri Nov 25, 2022 5:00 pm

Hello Hans,

You are always welcome!
The question which I could not answer so far is, where do I enter the condition? I searched AI up and down for a field named "condition" that was connected to the feature but with no success.
You can see the condition field by going to "Organization" page --> select any feature --> "Installation Behavior" section.

There, since we are in the second scenario from above, we can set the behavior to "Not installed" and input the name of the property in the "Installed if" field.
Screenshot_27.png
Screenshot_27.png (50.17KiB)Viewed 5253 times

Regarding the search question, searches are executed right at the start of the installation during the "Search" action group (you can go to "Custom Actions" page and there you can form an ideea on when the search is executed in contrast to your other actions).

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

hsc
Posts: 71
Joined: Wed Mar 02, 2016 2:55 pm

Re: Install a component only if a registry entry exists

Wed Dec 21, 2022 1:47 pm

Hi Catalin,

sorry it took me so long to verify this. Today I implemented it and - it works! Thanks a lot!

Hans

Catalin
Posts: 6537
Joined: Wed Jun 13, 2018 7:49 am

Re: Install a component only if a registry entry exists

Wed Dec 21, 2022 2:18 pm

You are always welcome, Hans!

Glad to hear it worked. :)

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

Return to “Common Problems”