2

If Property ELECTRICAL_VERSION has 12.1.7.2,12.1.5.2 or any value the condition is evaluated as true and custom action is being executed. I want it to skip if the value is less than 12.1.7.2.

<Property Id="ELECTRICAL_VERSION" Secure="yes">
  <RegistrySearch Id="ELECTRICAL_VERSION" Root="HKLM" Key="SOFTWARE\WOW6432Node\12.1.7" Name="ProductVersion" Type="raw" />
</Property>

 <CustomAction Id="ElectricalInstallCheck" Execute="immediate" Property="ELECTRICAL_VERSION" Return="check" Value=""/>
<InstallExecuteSequence>
<Custom Action="Install" Before="WriteRegistryValues">ELECTRICAL_VERSION>="12.1.7.2"</Custom>

1 Answers1

0

Maybe try NOT ELECTRICAL_VERSION<"12.1.7.2".

In your WiX source, escape the < character: NOT ELECTRICAL_VERSION&lt;"12.1.7.2".

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • Yes it worked but I have one question, Can we give multiple comparison conditions in custom action? EX: $License=3 AND ELECTRICAL_VER AND ELECTRICAL_VER<"12.1.7.2" – user3432571 Sep 15 '18 at 18:18
  • You can AND and OR conditions as you please, but doing so tends to cause confusion rather quickly. Conditions can be hard to test. That being said, the condition you indicate looks pretty simple. There is a trick, you can use a custom action to invoke [Session.EvaluateCondition](https://learn.microsoft.com/en-us/windows/desktop/msi/session-evaluatecondition)("CONDITION HERE") to verify the validity of your condition at runtime at various sequence positions - if you venture into very advanced conditions that can be affected by sequencing issues (when the custom action runs). – Stein Åsmul Sep 15 '18 at 20:51
  • Great, [maybe have a quick look here (bottom)](https://stackoverflow.com/a/52377800/129130) for a simple way to test components using scripts and message boxes - a variant of the Session.EvaluateCondition("Some Conditon") message box approach. Use only for debugging and testing please (easy to forget to take out sometimes). – Stein Åsmul Sep 19 '18 at 10:40