Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有自己的 Windows 服务。我想获取服务的 PID,然后在 cmd 中将其杀死。
哪个命令可以为我做到这一点?
您可以tasklist用来枚举进程:
tasklist
@echo off for /f "tokens=2" %%p in ('tasklist /fi "imagename eq your_svc.exe" /nh') do ( set PID=%%p )
然后通过以下方式终止进程taskkill:
taskkill
taskkill /pid %PID%