If statement help - ActionScript/Relevance

I have and if statement that I am running but when I run against a test machine it deletes everything and then reboots the machine.I added the or in the Displayversion. But if I leave the OR our and just look for version 8.0.920.14 it works fine. Any help would be great…

IF{exists keys whose (value "DisplayName" of it as string as lowercase contains "java" AND (value "Publisher" of it as string as lowercase contains "oracle" OR value "Publisher" of it as string as lowercase contains "sun") AND value "DisplayName" of it as string as lowercase does not contain "java auto updater" AND value "DisplayVersion" of it as string as lowercase does not contain "8.0.920.14" or value "DisplayVersion" of it as string as lowercase does not contain "8.0.910.14") of keys "hklm\software\microsoft\windows\currentversion\uninstall" of (native registry;registry)}

Not a lot of context to work with there, but I gather you’re trying to find Java versions that are not 8.0.910.14 or 8.0.920.14? Assuming that the values you list are correct, I think you have a scoping/parentheses problem -

value "DisplayName" of it as string as lowercase contains "java" AND (value "Publisher" of it as string as lowercase contains "oracle" OR value "Publisher" of it as string as lowercase contains "sun") AND value "DisplayName" of it as string as lowercase does not contain "java auto updater" AND value "DisplayVersion" of it as string as lowercase does not contain "8.0.920.14" or value "DisplayVersion" of it as string as lowercase does not contain "8.0.910.14"

Evaluates as
"java" AND ("oracle" or sun) AND "not java updater" AND "not version 8.0.920.14" OR not "8.0.910.14"

That very last OR gets you…so that every product in the Uninstall key that happens to not be version 8.0.910.14 matches this whole clause. The boolean logic works like this…
q: true and true and false or true
A: True

I think you could rewrite as
value "DisplayName" of it as string as lowercase contains "java" AND (value "Publisher" of it as string as lowercase contains "oracle" OR value "Publisher" of it as string as lowercase contains "sun") AND value "DisplayName" of it as string as lowercase does not contain "java auto updater" AND (value "DisplayVersion" of it as string as lowercase does not contain "8.0.920.14" or value "DisplayVersion" of it as string as lowercase does not contain "8.0.910.14")

…just wrapped the version checks in a parenthesis so the clause is AND (version1 or version2)

1 Like

It would be helpful to know what you are trying to achieve in order to properly advise you on the right relevance statement.

@JasonWalker is definitely on to part of the problem with the boolean logic.

I think you actually want AND between all of the statements:

value "DisplayVersion" of it as string as lowercase does not contain "8.0.920.14" AND value "DisplayVersion" of it as string as lowercase does not contain "8.0.910.14"

But it is hard to say for sure without knowing the goal.

The goal is not to uninstall all versions of java other than the two stated in the statement. So I am grabbing all the reg keys for the versions and adding them to a text file where I use it in a powershell script to uninstall using the msiexec.exe .
So basically making sure all versions get uninstalled other than java92 and java91.

Quite right, I think it probably should be an “AND” in the check for the two versions.