lolalola
lolalola

Reputation: 3823

python and process

What is the best way in python find the process name and owner?

Now i use WMI, but this version is too slow.

Upvotes: 0

Views: 344

Answers (2)

Giampaolo Rodolà
Giampaolo Rodolà

Reputation: 13056

By using https://github.com/giampaolo/psutil:

>>> import psutil, os
>>> p = psutil.Process(os.getpid())
>>> p.name()
'python.exe'
>>> p.username()
'giampaolo'
>>> 

Upvotes: 1

Will Robinson
Will Robinson

Reputation: 2289

Process name: is sys.argv[0] not sufficient for your purposes?

Upvotes: 0

Related Questions