One of my programs outputs its thread ID for debugging purposes. For testing reasons I'd like to kill the process to which the thread ID belongs.
How do I get the process ID if I have the thread ID so that I can use it with taskkill
?
I tried
tasklist
but it doesn't seem to have a switch for thead IDs.- SysInternals Process Explorer's "Find handle" feature, which works, but I'd need something that can be automated in a batch file
- SysInternals Handle
-a Thread
, but that doesn't seem to work.handle -a | find "Thread"
works better, but I lose the process information
findstr
or similar. But yeah, tools for Windows don't generally assume you are trying to go from thread ID to process ID; it's usually the other way around.tid2pid
does not exist, I'd rather write one