Registry exists problem

(imported topic written by sinucus)

I’m writing some relevance and I finally got a working version of it but I feel that it is terrible code and I’m looking for some help understanding a better way to write this code.

if (exists key whose (name of it contains “for_KB2779768”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\ApplicabilityEvaluationCache” of native registry) then if (exists (value “ApplicabilityState” of key whose (name of it contains “for_KB2779768”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\ApplicabilityEvaluationCache” of native registry)) then value “ApplicabilityState” of key whose (name of it contains “for_KB2779768”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\ApplicabilityEvaluationCache” of native registry != 80 else true else false

What I’m looking for is to search for a registry key, check to see if it has a value and then checking the data of it. The problem that I kept running into was with the “name of it ‘contains’” section. When the key didn’t exist, the whole relevance broke.

Thanks in advance

(imported comment written by jeremylam)

You can simplify this statement considerably using plurals, but it involves understanding that plurals evaluate sets of items, with the possibility of a set containing zero items.

At every level of the statement, instead of saying key or value, it uses “keys” and “values”, implicitly accepting the possibility that there may be no keys or values at all.

exists (it != 80) of values “ApplicabilityState” of keys whose (name of it contains “for_KB2779768”) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Component Based Servicing\ApplicabilityEvaluationCache” of native registry