DisplayName contains & not contains

Trying to pull architecture of 7-Zip,

x64 part of relevance is perfectly working fine but not sure why its getting x86 even if 7-Zip not installed.

Q: if (not Windows of operating system) then "N/A" else if exists (value "DisplayName" of it as string as lowercase starts with "7-Zip" as lowercase) of keys whose (value "DisplayName" of it as string contains "x64 edition") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if x64 of operating system then (x32 registry; x64 registry) else registry) then "x64" else if exists (value "DisplayName" of it as string as lowercase starts with "7-Zip" as lowercase) of keys whose (value "DisplayName" of it as string as lowercase does not contain "x64 edition") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if x64 of operating system then (x32 registry; x64 registry) else registry) then "x86" else "None"
A: x86
T: 1.162 ms

Difference between DisplayName of x64 bit & x86 is, x64 7-Zip contain x64 edition in its Display Name but for x86 its just 7-Zip & version.

I’ll try to write more detail later, but I think you are confusing ‘if’ with ‘whose’

if exists (value "DisplayName" of it as string as lowercase starts with "7-Zip" as lowercase)

The value "DisplayName" part may evaluate as False, but ‘False’ exists so the If statement matches as true.

1 Like

I think this may also due to searching within a string for a string that does not exist, eg an empty string does not contain “x64 edition”

Q: exists (value "DisplayName" of it as string as lowercase starts with "NothingThatExists" as lowercase) of keys whose (value "DisplayName" of it as string as lowercase does not contain "x64 edition") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if x64 of operating system then (x32 registry; x64 registry) else registry)
A: True
T: 0.284 ms
I: singular boolean

Q: if exists (value "DisplayName" of it as string as lowercase starts with "NothingThatExists" as lowercase) of keys whose (value "DisplayName" of it as string as lowercase does not contain "x64 edition") of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if x64 of operating system then (x32 registry; x64 registry) else registry) then "x86" else "None"
A: x86
T: 0.293 ms
I: singular string

One other way that may work for you

Q: (if (it contains "x64") then ("x64") else (if (it contains "7-zip") then ("x86") else "None")) of (concatenation ";" of ((values "DisplayName" whose (it as string as lowercase contains "7-zip") of keys of keys "HKLM\Software\Microsoft\Windows\CurrentVersion\Uninstall" of (x32 registry ; x64 registry)) as string as lowercase))
A: x64
T: 47.008 ms
I: singular string

Of course there is always more than one way to do something with Bigfix and someone else may be a more suitable method. My attempt will not cater for cases where both x86 and x64 versions are installed, it will report as x64 in that case

1 Like