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”
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
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 "..."