michael@bitplane.com
Posts: 7
Joined: Tue Feb 23, 2016 4:45 pm

Setting registry value depending on installed feature

My Installer consists of two feature let's say "MainFeature" and "OptionalFeature". Now what I like to have is a registry value "IsOptionalFeatureInstalled" set to either true/false depending on whether "OptionalFeature" got installed or not.

This registry value should also be updated in case of uninstallation/repair/later installation of the feature "OptionalFeature".

How can I do this?

Many Thanks
Michael
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Setting registry value depending on installed feature

Hi Michael and welcome to Advanced Installer forums,

Please note that you can create the related registry key in the Registry view. You can also take a look on the Add registry keys and values to your package article which may be useful to you.

Note that when you added the related registry, a new component has been added in the Organization page. Use the Go to component option from the context menu of the registry. Drag this component under the optional feature, as you can see below:
Organization view.png
Organization view.png (15.9 KiB) Viewed 4501 times
Should there be any difficulty you encounter implementing something, please do not hesitate to contact me and I will gladly assist.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
michael@bitplane.com
Posts: 7
Joined: Tue Feb 23, 2016 4:45 pm

Re: Setting registry value depending on installed feature

Hi Dan,

Many thanks for your quick replay.

I understand what you did and this should be sufficient to implement the desired behavior that we want in our application.

Now just out of curiosity: how would you set a specific value (true/false) to registry value "IsOptionalFeatureInstalled" depending on whether a feature is installed or not?

Best Regards,
Michael
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Setting registry value depending on installed feature

You're welcome Michael,

Why don't you set the registry value as true right from the begining. If the registry exists, then the feature is installed. If the registry does not exist, then the feature was not installed.

Please let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
michael@bitplane.com
Posts: 7
Joined: Tue Feb 23, 2016 4:45 pm

Re: Setting registry value depending on installed feature

Hi Dan,

Yes, this is what we are doing now and working fine.

But still let's say the registry value is not a bool but stores some state like "ViewMode" as a string and the value depends on installed feature. How can you archive this?

Michael
Dan
Posts: 4513
Joined: Wed Apr 24, 2013 3:51 pm

Re: Setting registry value depending on installed feature

Hi Michael,

You can set the related property using the Set Installer Property predefined custom action. You can condition its execution so it only be executed if the OptionalFeature was scheduled for installation e.g the condition is something like that:

Code: Select all

&OptionalFeature=3
For details, please take a look on the Edit Condition Dialog article with related information for hints and guidance. Also, please take a look on the Session.FeatureRequestState property article which may be useful to you.

Let me know if you have any questions.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
Marek P.
Posts: 1
Joined: Wed May 29, 2019 12:01 pm

Re: Setting registry value depending on installed feature

I have similar problem

I want to set the same registry key value with different data based on instaled Feature

key: HKLM\SOFTWARE\MyApp
the Value is MachineType DWORD

data is based on instaled feature : 1 or 2 or 3 or 4

Code: Select all

[HKEY_LOCAL_MACHINE\SOFTWARE\MyApp]
"MachineType"=dword:00000007
Catalin
Posts: 6586
Joined: Wed Jun 13, 2018 7:49 am

Re: Setting registry value depending on installed feature

Hello Marek and welcome to Advanced Installer forums,

Since you have 4 features, we may need 4 registry values (because we can not have the same name for a registry value): InstalledFeature1, InstalledFeature2, InstalledFeature3, InstalledFeature4.

These values can be added in "Registry" page, like this:
Registry.PNG
Registry.PNG (145.9 KiB) Viewed 3542 times
In the "Organization" page, you should have the 4 features, similar to this:
Features.PNG
Features.PNG (122.34 KiB) Viewed 3542 times
As you can see in the above screenshot, 4 new components were created for each of our registry values, i.e. InstalledFeature1, InstalledFeature2, InstalledFeature3, InstalledFeature4.

Simply drag and drop these components under its own feature:
Capture.PNG
Capture.PNG (113.91 KiB) Viewed 3542 times
Hope this helps.

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

Return to “Building Installers”