Is there a cleaner way to retrieve and assign the service name to a variable in cmd ?
My current attempt:
set svc_query="sc queryex type= service state= all | find /i "plusfield" | find /i "service""
for /F "tokens=*" %%i in (' %svc_query% ') do set x=%%i
Which gets me x = SERVICE_NAME: PlusField01 so i remove the SERVICE_NAME: part
set svc=%x:~14%
echo %svc%
PlusField01
It works but as as a newb on cmd it seems that something its not right and maybe theres a cleaner way of doing it