The query language

Ask the machine a question

One language, in the search box of the window and in bws list --query. A bare word searches the name, the display name, the account and the launch path. A field narrows it. 21 fields, and the same text means the same thing in both halves of the tool.

Five that answer a real question

What should be up and is not

start:auto !status:running

The first query most people write, and the one services.msc cannot answer at all.

Services whose file is gone

file:missing

An entry pointing at a binary that is not on disk. Usually an uninstall that left the registration behind.

Unsigned, without the session noise

signed:no peruser:no

The per-user families make a copy per session and fill a list with near-duplicates. This asks about the rest.

Running although disabled

mismatch:running

Configuration and state that disagree - an entry the manager is set never to start, running anyway.

Anything asking for debug rights

privilege:SeDebugPrivilege

A privilege that lets a process open any other one. Worth knowing which services ask for it.

What the tool could not read

account:?

The entries where this session could not read the account. A question services.msc cannot even ask.

How a query is written

Terms

  • Terms are separated by spaces and all of them must match - there is no and keyword because there is nothing else it could mean.
  • ! in front of a term negates it: !status:running.
  • A comma inside a field is or: start:manual,disabled.
  • Quotes protect anything with spaces or colons: account:"NT SERVICE\McmSvc".

How text is matched

  • name:spool matches anything containing it - the default, because it is what people expect from a search box.
  • name:=spooler is exact.
  • name:spool* takes wildcards, * and ?.
  • name:/^Sql.*/ is a regular expression.
  • Case is ignored, including outside ASCII - a display name in Polish or Greek matches whichever way it is typed.

Three words every field accepts

  • any - there is a value, whatever it is
  • none - there is genuinely no value - the entry has none
  • ? - the tool could not read this field, which is a question services.msc cannot even ask

A mistyped value is an error, never an empty result. status:runing answers Did you mean running? and ends with code 2. An empty list would look like an answer, and the difference between "nothing matches" and "you typed it wrong" is the difference between a machine that is clean and an audit that proved nothing. A query that would narrow nothing is refused on the command line too, so a script does not operate on the whole machine because of a typo.

Every field

Built from the program itself, so this table cannot drift from what the tool accepts. A field with no list of values takes text, a number or a size - the third column says which.

FieldAsks aboutValues
namethe service name, the one Windows identifies it bytext
displaythe display name, as this Windows spells ittext
descriptionwhat the entry says about itselftext
typewhat kind of entry it isdriver, kernelDriver, fileSystemDriver, ownProcess, sharedProcess, unknown
peruserwhether it is one of the per-user families Windows makes a copy of per sessionyes, no, template, instance
statuswhat it is doing right nowrunning, stopped, paused, pending, startPending, stopPending, pausePending, continuePending, unknown
startwhat the manager does with it at the next bootautomatic, auto, delayed, manual, disabled, boot, system, unknown
accountthe account it runs as, as the manager spells ittext, e.g. localsystem
pidthe process it is running ina number: 1234, >1000, 100-200
triggera condition that starts or stops itdevice, ip, domain, firewall, policy, network, custom, state, unknown, start, stop
paththe command line the manager launchestext
filewhether the file it runs is on diskpresent, missing
signedwhat Windows thinks of the file's signatureyes, no, trusted, notSigned, untrustedRoot, expired, revoked, tampered, unknown
publisherwho signed the filetext
privilegea privilege the entry asks fortext, e.g. SeDebugPrivilege
dependsonwhat this one needsa service name
requiredbywhat breaks if this one stopsa service name
sidtypethe service SID typeunrestricted, restricted, unknown
sddlthe security descriptor, as texttext
memorywhat its process is usinga size with a unit: 500MB, >1GB, 100MB-1GB
mismatchconfiguration and state that disagreestopped, running

Two things worth knowing

Some fields are expensive, and asking for them turns the reading on

Signatures take several seconds over a whole machine and memory is a measurement rather than a setting, so neither is read for a listing unless asked. A query that mentions one turns that reading on by itself - you do not have to remember --signatures as well as signed:no. In the window, a query about signatures says the answer is incomplete until they arrive, rather than showing a shorter list as though it were the answer.

A result judged on something unreadable says so

If entries were judged on a field this session could not read, the result carries a line saying how many - because such a result may be missing entries, or holding ones that do not belong. That is the same rule the whole tool keeps: an unsuccessful read is visible in the answer, never swallowed.

The command line reference