Evaluate if registry value IS NOT 1 or 0

I am trying to evaluate if a registry value IS NOT zero or one. I am using the following code but it always evaluates to true, evem if the value is something other than 0 or 1. I have searched the forum but can’t find an topic that addresses my issue.

code:
If ( exists key “HKEY_LOCAL_MACHINE\SYSTEM\Key_Name” of native registry ) and ( exists value whose (name of it is “Value_Name” and ( it is not “0” OR it is not “1” ) ) of key “HKEY_LOCAL_MACHINE\SYSTEM\Key_Name” of native registry ) then “VALUE NOT SET CORRECTLY, It must be ‘0’ or ‘1’” Else “Rest of Script”

Where is my error?

Cheers,
E

I wonder if the issue is due to the data type? See samples below where we cast the value to an integer prior to the comparison operator:

Q: values "Value_Name" of keys "HKLM\SYSTEM\Key_Name" of native registry
A: 1
T: 0.215 ms
I: plural registry key value

Q: (it as integer != 0 AND it as integer != 1) of values "Value_Name" of keys "HKLM\SYSTEM\Key_Name" of native registry
A: False
T: 0.115 ms
I: plural boolean
1 Like

I tried to keep it similar to what you already have. Give this a try.

if not exists keys "HKLM\...\...\...\" whose(exists values whose(name of it = "" AND it as integer = 0 OR name of it = "" AND it as integer = 1)of it) of (x32 registries;x64 registries) then "..." else "..."

‘it is not 0 or it is not 1’ will always be true.
If it’s 0, then it will match ‘or it is not 1’.
If it’s 1, it will match ‘it is not 0’

You need ‘not 0 and not 1’, or ‘it is 0 or it is 1’

2 Likes

That did it. Changed the OR to AND, and nothing else, and BOOM!

Thanks,
E

1 Like