Dinko Pehar
Dinko Pehar

Reputation: 6061

Is there anyway to get process info by PID or name on Windows using Python?

I need to get process info by using PID or Name on Win 10, using only standard library.

Is this possible?

EDIT:

I meant all processes, not current...

Upvotes: 1

Views: 1130

Answers (1)

Ricky Kim
Ricky Kim

Reputation: 2022

You can use subprocess

from subprocess import getoutput

process_info = getoutput('wmic process where "name like \'%{}%\'" get Caption,ExecutablePath,Processid,CommandLine'.format('chrome.exe'))

process_info = getoutput('wmic process where "ProcessID={}" get Caption,ExecutablePath,Processid,CommandLine'.format(14520))

Upvotes: 1

Related Questions