Reputation: 13778
I need to author a WiX bundle that will not run unless a certain registry key is present on the system.
In a normal setup project, I would use a Launch Condition, but I'm not authoring the setup project, just the top level bundle. The <Bundle>
element has a Condition
attribute, but in the Burn manual it says:
The condition of the bundle. If the condition is not met, the bundle will refuse to run. Conditions are checked before the bootstrapper application is loaded (before detect), and thus can only reference built-in variables such as variables which indicate the version of the OS.
So it appears that I can't use the Condition
attribute of the Bundle
element for anything but the most basic high level checks, and certainly not for what I need.
So how can I check for a registry key at the bundle level and refuse to continue if the key is absent?
Upvotes: 2
Views: 666
Reputation: 4798
You definitely can do registry searches in your bundle then base a condition on the results of those registry searches since I do exactly that in several bootstrapper projects. Not exactly sure what the documentation is referring to but either it is out of date or just wrong.
As a quick example I have:
<util:RegistrySearch
Id="ServerInstalledCheck"
Root="HKLM"
Key="SOFTWARE\$(var.OEMRegistryRootKeyName)"
Value="ServerPath"
Result="value"
Variable="ServerInstalled"/>
<bal:Condition Message="#(loc.ServerNotInstalledError)" >ServerInstalled OR WixBundleInstalled</bal:Condition>
And this will stop your bundle from installing if it couldn't find the ServerPath key @HKLM\SOFTWARE\$(var.OEMRegistryRooteKeyName)
I'also added OR WixBundleInstalled
since you can have an issue where somehow the customer uninstalled all or some of the packages included in your bootstrapper (including the one that the registry search depends on) and then you will be forever unable to uninstall your bootstrapper until you manually re-add the registry key.
Upvotes: 5