I am trying to get several values from a query to put in to a property. However, I cannot find the variable to use to get the general description of each service. Here is what I have:
q:(service names of it, display name of it, image paths of it, state of it) of services
I actually don’t have a working answer for you as these are the types of problems I always run into with relevance.
The following line returns the services as 1 line each but it outputs terribly. I think it has to do something with UTF-8 encoding. Hopefully one of the other relevance experts can chime in here…
q: select objects (“name, description from win32_service”) of wmi
Actually, try this… It might bomb out on you if one of the properties is missing though.
q: ((substring after “=” of (property “Name” of it as string) & ", " & (substring after “=” of (property “Description” of it as string)) & ", " & (substring after “=” of (property “PathName” of it as string)) & ", " & (substring after “=” of (property “State” of it as string))) of select objects (“Name,Description,PathName,State from win32_service”) of wmi)
( string value of property “name” of it,
string value of property “description” of it,
string value of property “pathname” of it,
string value of property “state” of it
) of select objects “* from win32_service” of wmi
Thanks for you input on this, your code is definitely cleaner than mine, but it still breaks the same way as mine.
If one of the fields is missing it returns a E: Singular expression refers to nonexistent object and stops processing. We need to throw some “if exists” in there somewhere.
how about adding the “| “n/a”” to the statement. For example:
(string value of property “name” of it | “n/a”, string value of property “description” of it | “n/a”, string value of property “pathname” of it | “n/a”, string value of property “state” of it | “n/a”) of select objects “* from win32_service” of wmi