I am struggling really hard with parsing the output of the SC.EXE command. I want to list all services (active or inactive) that have "text" in their name.
The following code is looking for eventlog:
FOR /F "usebackq" %%G IN (`"sc query state= all" ^| find "eventlog"`) DO echo [%%G]
It would all work if it was not for the state= all
parameter that you need to pass to the SC command so that you will get even inactive services.
For some not so clear reason the values for parameters in the SC command need to be separated by space and that's causing a lot of confusion.
Any help is greatly appreciated!