Question: I am trying to stop multiple services remotely without using the full name using a wild card in a batch file. Something like this **service\***

Here are a couple example commands I'm using for my need but as you can see I have to explicitly specify the full name of the process and I cannot use wildcards to find matches to run commands to manipulate those process names. 

```
taskkill /s server1 /im service2018.EXE
sc.exe \\server1 start service1

taskkill /s server2 /im service2018.exe
sc.exe \\server2 start service2

```

Answer: 
What you can do is use [tasklist](http://ss64.com/nt/tasklist.html) with the `/FO LIST` options and then pipe that over to a couple [find](http://ss64.com/nt/find.html) commands with the `/I` switch to search the wildcard keyword as desired.

You can run that through a [FOR /F](http://ss64.com/nt/for_cmd.html) loop using `"DELIMS=: TOKENS=2"` along with the [variable substring](http://ss64.com/nt/syntax-substring.html) trick to parse out empty spaces to return the matching process name(s) to then kill, etc.

Batch Script
------------

```
SET SrvName=Server1
SET Wildcard=service

SETLOCAL ENABLEDELAYEDEXPANSION
FOR /F "DELIMS=: TOKENS=2" %%A IN ('TASKLIST /S %SrvName% /FO LIST ^| FIND /I "Image name:" ^| FIND /I "%Wildcard%"') DO (
    SET var=%%~A
    SET var=!var: =!
    ECHO !var!
    taskkill /s %SrvName% /f /im !var!
)

```

---

Further Resources
-----------------

* [EnableDelayedExpansion](http://ss64.com/nt/delayedexpansion.html)
* [FOR /F](http://ss64.com/nt/for_cmd.html)
* [Variable Substring](http://ss64.com/nt/syntax-substring.html)
* [Tasklist](http://ss64.com/nt/tasklist.html)
* [Find](http://ss64.com/nt/find.html)
* [Taskkill](http://ss64.com/nt/taskkill.html)
I was killing the service because the service name was consistent but to start the service the full name was never the same on the multiple servers. I figured this command works for me to start a service on a remote computer without the full name:

WMIC/node:server1 service where "name like 'service%%'" call startservice