donaddon
Posts: 15
Joined: Wed Apr 30, 2014 6:21 pm

Create registry key only if property exists

I want to support optional parameters for my installer. For example:

msiexec /i myinstaller.msi INSTALL_REG_ID="heij3jlncnlnlndjl"

And this installer will only create the registry key IF that parameter is supplied.

To accomplish this, I created the registry key entry with the key name I wanted based on the property:

/.../Extensions/[INSTALL_REG_ID]/

And a value under that key:

update_url = "https://www.someurl.com"

This works great when I supply INSTALL_REG_ID.

However, when I don't supply it, it automatically tacks the update_url value under the parent registry key (in this case "Extensions").

What I'd like is for that value to not be created at all when I don't supply the INSTALL_REG_ID property on the command line.

What's the easiest way to do this? Will it require a custom action to check for the existence of the property?

Thanks!
Dan
Posts: 4529
Joined: Wed Apr 24, 2013 3:51 pm

Re: Create registry key only if property exists

Hello,

In order to achieve that you can condition the creation on the related registry key through its component's condition field.

Please note that when you add registry key to your package, automatically a new component is created in the Organization page.

Through the Condition field from the component properties you can condition the installation of the related component. If the condition is null or is evaluated to false, the component is not installed, so the registry entry is not created.

Please let me know if that helped.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
donaddon
Posts: 15
Joined: Wed Apr 30, 2014 6:21 pm

Re: Create registry key only if property exists

Hi Dan,

Thanks, that worked. The step I overlooked was setting the condition on the actual registry value, not just the parent key. Otherwise the registry value was still being created under an empty parent registry key (the registry key named by the non-supplied command-line parameter), thus ending up in the parent registry key.

Thanks!
- Don
Dan
Posts: 4529
Joined: Wed Apr 24, 2013 3:51 pm

Re: Create registry key only if property exists

You're welcome Don,

If you have other questions, please let us know.

Best regards,
Dan
Dan Ghiorghita - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”