Created
December 4, 2017 11:01
-
-
Save dinya/739929f0386c313db433a0b5fb64c161 to your computer and use it in GitHub Desktop.
Get process list (name, pid) on win32 with python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| import re | |
| def get_process_list_win32(): | |
| regexp = ur"^(?P<name>.*) \s+(?P<pid>\d+) [S|C].*$" | |
| l = [] | |
| for i in os.popen('tasklist').readlines()[5:]: | |
| g = re.search(regexp, i.decode("cp866").rstrip()) | |
| name = g.group("name").rstrip() | |
| pid = g.group("pid") | |
| l.append((name, pid)) | |
| return l |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment