RESOLVED: Using OR with IF/THEN/ELSE Fails

So i know using plurals might be an option here, but the goal is to create custom results for the requestor So I believe the logic failure is that it wants to see one value, and doesn’t support the AND command in the same string. So how do I get around this?

IF (exists (hexadecimal string it) whose(it contains “value1” AND it does not contain “value2”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries) THEN “Missing” ELSE (exists (hexadecimal string it) whose(it contains “value1” AND it contains “value2”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries) THEN “Current to WScript” ELSE “Unexpected Value”

How do I get around this?

Thanks!

It looks like you just need an if statement for your second set of if/then/else and paranethesis around your other statements

IF (exists ((hexadecimal string it) whose(it contains "value1" AND it does not contain "value2")) of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "Missing" ELSE if (exists (hexadecimal string it) whose(it contains "value1" AND it contains "value2") of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "Current to WScript" ELSE "Unexpected Value"

Something like this might be shorter:

((if (it contains "value1" and it does not contain "value2") then ("Missing") else ((if (it contains "value1" and it contains "value2") then ("Current to WScript") else ("Unexpected Value")) of it))) of ((hexadecimal string it) of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries))

Thanks for the reply, but that didn’t work. I replaced the values with the correct values and it can’t even see the key now (and I verified it’s there). It simply returns:

Singular expression refers to nonexistent object

Which did not work the shorter one or the “fixed” longer one?

Generally you should use the following format for if\then\else statements if you’re going to be nesting them:

(if (true) then (this) else (that))

If you break up your relevance into pieces and let us know which piece isn’t working we can try to help but it’s hard to test this because most of us won’t have McAfee on our systems.

The Fixed longer one didn’t work.

Breaking it down:

(exists (hexadecimal strings it) whose(it contains “SCR” AND it does not contain “wscript”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries)

Works Fine

(exists (hexadecimal strings it) whose(it contains “SCR” AND it contains “wscript”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries)

Works File

IF (exists (hexadecimal strings it) whose(it contains “SCR” AND it does not contain “wscript”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries) THEN “Missing WScript” ELSE IF (exists (hexadecimal strings it) whose(it contains “SCR” AND it contains “wscript”)) of unique values of (it as string) of values “AccessProtectionUserRules” of keys “HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking” of (x64 registries; x32 registries) THEN “Current to WScript” ELSE “Unexpected Value”

Results:A singular expression is required.

It doesn’t look like that’s the relevance that I posted:

Right away mine has If (exists ((hexadecimal and yours is missing the open parenthesis

IF (exists ((hexadecimal string it) whose(it contains "value1" AND it does not contain "value2")) of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "Missing" ELSE if (exists (hexadecimal string it) whose(it contains "value1" AND it contains "value2") of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "Current to WScript" ELSE "Unexpected Value"

Your code suggestion results in: Singular expression refers to nonexistent object. when there is a key and value under the 64Bit Registry.

What do these produce?

First

if (exists ((hexadecimal string it) whose(it contains "value1" AND it does not contain "value2")) of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "THEN" ELSE "ELSE"

Second

if (exists (hexadecimal string it) whose(it contains "value1" AND it contains "value2") of unique values of (it as string) of values "AccessProtectionUserRules" of keys "HKEY_LOCAL_MACHINE\SOFTWARE\McAfee\SystemCore\VSCore\On Access Scanner\BehaviourBlocking" of (x64 registries; x32 registries)) THEN "THEN" ELSE "ELSE"
1 Like

So you’re #1 returned

Singular expression refers to nonexistent object.

You’re #2 seemed to work - Returning

THEN

The big difference between you relevance is that yours is a Singular String and mine was based on plural boolean. Repeating the code now gives the desired result.

Thank you!