Reputation: 465
I have an own windows service. I want to get the PID of the service and then kill it in the cmd.
Which command could do this for me?
Upvotes: 2
Views: 3829
Reputation: 200453
You could use tasklist
to enumerate the processes:
@echo off
for /f "tokens=2" %%p in ('tasklist /fi "imagename eq your_svc.exe" /nh') do (
set PID=%%p
)
and then kill the process via taskkill
:
taskkill /pid %PID%
Upvotes: 6