Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(Windows) directly determine process exe instead of guessing it from cmdline #293

Closed
giampaolo opened this issue May 23, 2014 · 3 comments
Closed

Comments

@giampaolo
Copy link
Owner

From g.rodola on June 29, 2012 05:31:20

As of right now on Windows we determine the process executable path by guessing 
it from the cmdline: 
https://code.google.com/p/psutil/source/browse/tags/release-0.5.0/psutil/_psmswindows.py#167

https://code.google.com/p/psutil/source/browse/tags/release-0.5.0/psutil/__init__.py#224
 This is unfortunate because cmdline raises AccessDenied for almost any process 
except the ones owned by the current user.
In r1394 I used GetProcessImageFileName() which fails less often and avoids the 
cmdline guessing.

Example script:

for p in sorted(psutil.process_iter(), key=lambda x: x.pid):
    print p.pid,
    try:
        print p.exe
    except psutil.AccessDenied, err:
        print 'AD'

===============================
Before
===============================

0 AD
4 AD
268 AD
300 AD
356 AD
392 AD
404 AD
432 AD
488 AD
504 AD
512 AD
540 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
556 AD
616 AD
672 AD
700 AD
756 AD
852 AD
856 AD
876 AD
936 AD
1032 AD
1224 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
1268 AD
1280 AD
1452 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
1552 AD
1584 AD
1760 AD
1836 AD
1860 AD
1984 AD
2004 AD
2144 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
2340 C:\Python27\python.exe
2808 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
3012 AD



===============================
Now
===============================

0 AD
4 AD
268 AD
300 AD
356 AD
392 AD
404 AD
432 AD
488 AD
504 AD
512 AD
540 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
556 AD
616 AD
672 AD
700 AD
756 AD
852 C:\Windows\System32\conhost.exe
856 C:\Windows\System32\cmd.exe
876 AD
936 AD
1032 AD
1224 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
1268 C:\Program Files\TortoiseSVN\bin\TSVNCache.exe
1280 AD
1452 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
1456 C:\Windows\System32\dllhost.exe
1468 C:\Python27\python.exe
1552 AD
1584 AD
1760 C:\Windows\System32\taskhost.exe
1836 C:\Windows\System32\dwm.exe
1860 C:\Windows\explorer.exe
1984 C:\Windows\System32\VBoxTray.exe
2004 C:\Program Files\TortoiseHg\TortoiseHgOverlayServer.exe
2144 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
2808 C:\Users\user\AppData\Local\Google\Chrome\Application\chrome.exe
3012 C:\Users\user\Desktop\procexp64.exe

Original issue: http://code.google.com/p/psutil/issues/detail?id=293

@giampaolo giampaolo self-assigned this May 23, 2014
@giampaolo
Copy link
Owner Author

From g.rodola on June 29, 2012 09:48:19

Labels: -Milestone-1.0.0 Milestone-0.5.1

@giampaolo
Copy link
Owner Author

From g.rodola on June 29, 2012 11:46:10

Status: Fixed

@giampaolo
Copy link
Owner Author

From g.rodola on March 02, 2013 04:09:55

Updated csets after the SVN -> Mercurial migration: r1394 == revision 
a8405e698412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant