Hi Guys, Im trying to do something I have done before. But for some reason… Im getting always false. I think its because the value is a REG_DWORD and the relevance I’m using is for a string. any ideas?
q: value "WriteProtect" of key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" of registry
A: 1
T: 0.098 ms
q: exists key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" whose (value "WriteProtect" of it = "1") of registry
A: False
T: 0.101 ms
q: if(exists key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" whose (value "WriteProtect" of it > "0") of registry) then("Active") else("Not Active")
A: Not Active
T: 0.139 ms
q: exists value "WriteProtect" whose (it != "0") of key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" of registry
A: True
T: 0.111 ms
If it’s not clear yet, I think the problem is that you’re comparing Integers to Strings. To illustrate,
Q: 1 = "1"
Should give False (or maybe an “Incompatible Types” error)
Q: 1 as string = "1"
Should give true
Q: 1 = “1” as integer
Should give true
q: exists key "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\StorageDevicePolicies" whose (value "WriteProtect" of it as integer = 1) of registry
Should give True in your case. Note I cast the value to type Integer for comparison. You could also get true via (value "WriteProtect" of it as string = "1")