Combining Windows reg query with service/process status query

I’m trying to get the combined/concatinated results of a relevance query back for ‘if some software is installed, and if so, what’s the version and running status’. Here’s the two queries separate that work, and then combined that returns “A singular expression is required.”. I’m used to working in Unix, so the Windows relevance is new to me.

Works: if (exists keys whose(exists (values “DisplayName” of it as string as lowercase, version of it) whose(it contains “chef client” as lowercase) ) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) then (values “DisplayVersion” of (keys whose(exists (values “DisplayName” of it as string as lowercase) whose(it contains “chef client” as lowercase) ) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) as string) as trimmed string else “Not Installed”

Works: if exists service “chef-client” then “Running” else “Not Running”

Returns the error: if (exists keys whose(exists (values “DisplayName” of it as string as lowercase) whose(it contains “chef client” as lowercase) ) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) then (values “DisplayVersion” of (keys whose(exists (values “DisplayName” of it as string as lowercase) whose(it contains “chef client” as lowercase) ) of keys “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall” of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) as string) & " | " & (if exists service “chef-client” then “Running” else “Not Running”) else “Not installed”

Because of the (x32 registry ; x64 registry) branch, you are getting a plural result sometimes and concatenation of strings with ampersand operator (&) only works on singulars.

You could concatenate your plural in the Then branch…

(Also, please use the CODE tag on your relevance to avoid the smart quotes it looks like </> in the editing bar)

Try:
q: if (exists keys whose(exists (values "DisplayName" of it as string as lowercase) whose(it contains "chef client" as lowercase) ) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) then (concatenation " ! " of (values "DisplayVersion" of (keys whose(exists (values "DisplayName" of it as string as lowercase) whose(it contains "chef client" as lowercase) ) of keys "HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall" of (if (x64 of operating system) then (x32 registry ; x64 registry) else (x32 registry))) as string)) & " | " & (if exists service "chef-client" then "Running" else "Not Running") else "Not installed"

That was the ticket! I’d tried the concatenation by wrapping the whole thing but it didn’t work. I figured I was on the right path thinking that it needed to be nested somewhere in the ‘then’ but was clueless as to where exactly to put it.

Thanks!