How do I get the PID of an EXE file from Windows command line?

I want to query the PID from the command line, rather than manually search in Task Manager.

I've found something similar in nix

2 Answers 2


PowerShell Get-Process can return the PID of running processes.

❯ Get-Process explorer

 NPM(K)    PM(M)      WS(M)     CPU(s)      Id  SI ProcessName
 ------    -----      -----     ------      --  -- -----------
    135   218.04     218.04     140.12   34304   3 explorer

❯ (Get-Process explorer).Id



In unlikely event that you don't want PowerShell then there is also tasklist

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .