I am trying to retrieve the version number of the “Diskeeper” application that is installed on my servers, the problem is that the registry entries are difference depending upon the version of the software or maybe the OS platform. I have isolated the two unique registry entries but when I try using the “OR” clause I get a “boolean expression is required” error
This query works on some machines but not on others.
q:if exists (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string else “not installed”
A: 20.0.593
The same with this query
q:if exists (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) as string else(“Not Installed”) OR ((if exists (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string else “not installed”))
A: 14.0.900
when I try putting a “OR” clause I get the error
E: A boolean expression is required.
q:if exists (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string else “not installed” OR ((if exists (value “DisplayVersion” of keys whose (name of it contains string “2D4A8333-8461-4601-96F7-D4E6FC1E0FA8”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “2D4A8333-8461-4601-96F7-D4E6FC1E0FA8”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string else if exists (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) as string else (“Not Installed”)))
Since I am unable to figure out how to prevent the "boolean expression is required: error from occurring because the registry key doesn’t exist. I though maybe someone could help me with a work-around.
I have this query that list all the installed application on the server, what I want to do see run this query and parse just one line of the output. I was think “TUPLE” item some number. please help thank you
how to parse one particular line from the output of this query
(if it = “” then nothing else it) of unique values of ((if (exists value"DisplayName" of it AND exists value “DisplayName” of it as string) then (value “DisplayName” of it as string) else ("")) & (if (exists value “DisplayVersion” of it AND exists value “DisplayVersion” of it as string) then (" | " & value “DisplayVersion” of it as string) else (""))) of keys whose (exists value “UninstallString” of it AND ((not exists value “SystemComponent” of it) OR (exists value “SystemComponent” of it AND name of it starts with “{” AND name of it contains “}” AND (exists match (regex “(9|A|B|C)(0|1)1(2|4)\d\d\d\d-(0011|0012|0013|0014|0017|002E|002F|0030|0031|0033|0035|003A|003B|0044|0051|0052|0053|0057|00BA |00CA|10D7|110D)-(0000|0409)-(0|1)000-(0|1)000000FF1CE$”) of preceding text of first “}” of following text of first “{” of name of it))) AND (if (exists value “DisplayName” of it AND exists value “DisplayName” of it as string) then ((it does not contain “Hotfix” AND it does not contain “Security Update for” AND it does not contain “Update for” AND it does not contain “Security Update for Windows” AND it does not contain “Update for Windows” AND it does not contain “Security Update for Microsoft” AND (length of it > 0) AND (number of substrings " " of it < length of it)) of (value “DisplayName” of it as string)) else true)) of keys “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if x64 of operating system then (x32 registry; x64 registry) else registry)
Between the two statements I first used the “OR” clause then I tried the “|” clause as AlanM suggested neither work. So after some time mucking around I found that instead of using ether OR/| I just removed the "else “Not installed” statement and used the else to extended to the second statement. (see below) and Thanks AlanM for your response and thanks to the entire membership.
The new query is:
if exists (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “490317DC-D849-45B7-B45C-9D6D9A933A28”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string
else
((if exists (value “DisplayVersion” of keys whose (name of it contains string “2D4A8333-8461-4601-96F7-D4E6FC1E0FA8”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “2D4A8333-8461-4601-96F7-D4E6FC1E0FA8”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of native registry) as string else if exists (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) then (value “DisplayVersion” of keys whose (name of it contains string “InstallProperties”) of key “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Installer\UserData\S-1-5-18\Products\7B0E47DF57382044AA783E3AED131428” of native registry) as string else (“Not Installed”)))
It turns out that I have allot more versions of diskeeper then I realized and although the relevance above works it only works for two versions. So I am back to using the relevance below,
just need to know how parse just the diskeeper line.
q:(if it = “” then nothing else it) of unique values of ((if (exists value"DisplayName" of it AND exists value “DisplayName” of it as string) then (value “DisplayName” of it as string) else ("")) & (if (exists value “DisplayVersion” of it AND exists value “DisplayVersion” of it as string) then (" | " & value “DisplayVersion” of it as string) else (""))) of keys whose (exists value “UninstallString” of it AND ((not exists value “SystemComponent” of it) OR (exists value “SystemComponent” of it AND name of it starts with “{” AND name of it contains “}” AND (exists match (regex “(9|A|B|C)(0|1)1(2|4)\d\d\d\d-(0011|0012|0013|0014|0017|002E|002F|0030|0031|0033|0035|003A|003B|0044|0051|0052|0053|0057|00BA |00CA|10D7|110D)-(0000|0409)-(0|1)000-(0|1)000000FF1CE$”) of preceding text of first “}” of following text of first “{” of name of it))) AND (if (exists value “DisplayName” of it AND exists value “DisplayName” of it as string) then ((it does not contain “Hotfix” AND it does not contain “Security Update for” AND it does not contain “Update for” AND it does not contain “Security Update for Windows” AND it does not contain “Update for Windows” AND it does not contain “Security Update for Microsoft” AND (length of it > 0) AND (number of substrings " " of it < length of it)) of (value “DisplayName” of it as string)) else true)) of keys “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if x64 of operating system then (x32 registry; x64 registry) else registry)
A: CA Access Control | 12.60.1156
A: CCleaner | 3.28
A: Defraggler | 2.13
A: Diskeeper 2010 Server | 14.0.900.64
A: Google Chrome | 25.0.1364.172
A: IBM 32-bit Runtime Environment for Java 2, v5.0 | 5.0
If you are simply interested in how many versions of “Diskeeper” you have installed in your environment, why not try something like …
values “DisplayVersion” of keys whose (exists value “DisplayName” whose (it as string as lowercase contains “diskeeper” ) of it of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry
to account for machines that may not have any software installed with a DisplayName containing “diskeeper” you would do something like this …
IF ((exists key whose (exists value “DisplayName” whose (it as string as lowercase contains “diskeeper” ) of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry)) THEN (values “DisplayVersion” of keys whose (exists value “DisplayName” whose (it as string as lowercase contains “diskeeper” ) of it of it) of key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of registry as string) ELSE (“N/I”)
Thanks Tim for your reply, The problem is the Diskeeper application doesn’t show up in the key “HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” that why I am using the relevance above - it finds the Diskeeper app. So I am trying to parse a single application name and version number from the output of the relevance above.
What if you added a little bit of relevance before your expression?
substrings before
"|" of (your giant relevance expression)
would get you the app names.
substrings after
"|" of (your giant relevance expression)
would get you the app versions. And you could filter for only diskeeper in your actual relevance expression so that all you see is diskeeeper results:
(
if it =
"" then nothing
else it) of unique values of ((
if (exists value
"DisplayName" of it AND exists value
"DisplayName" of it as string) then (value
"DisplayName" of it as string)
else (
"")) & (
if (exists value
"DisplayVersion" of it AND exists value
"DisplayVersion" of it as string) then (
" | " & value
"DisplayVersion" of it as string)
else (
""))) of keys whose (exists value
"UninstallString" of it AND ((not exists value
"SystemComponent" of it) OR (exists value
"SystemComponent" of it AND name of it starts with
"{" AND name of it contains
"}" AND (exists match (regex
"(9|A|B|C)(0|1)1(2|4)\d\d\d\d-(0011|0012|0013|0014|0017|002E|002F|0030|0031|0033|0035|003A|003B|0044|0051|0052|0053|0057|00BA |00CA|10D7|110D)-(0000|0409)-(0|1)000-(0|1)000000FF1CE$") of preceding text of first
"}" of following text of first
"{" of name of it))) AND (
if (exists value
"DisplayName" of it AND exists value
"DisplayName" of it as string) then ((it does not contain
"Hotfix" AND it does not contain
"Security Update for" AND it does not contain
"Update for" AND it does not contain
"Security Update for Windows" AND it does not contain
"Update for Windows" AND it does not contain
"Security Update for Microsoft" AND it contains
"Diskeeper" AND (length of it > 0) AND (number of substrings
" " of it < length of it)) of (value
"DisplayName" of it as string))
else
true)) of keys
"HKLM\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (
if x64 of operating system then (x32 registry; x64 registry)
else registry)