2

I know that there are a couple of ways to complete that task using psutil or win32ui modules. But I wonder if there's an option to do that using Python built-in modules only? I have also found this question:

Check if PID exists on Windows with Python without requiring libraries

But in this case the object is located by PID and I want to do it using process name.

Community
  • 1
  • 1
Eugene S
  • 6,412
  • 7
  • 58
  • 86

2 Answers2

5

Maybe this will help you:

import subprocess

s = subprocess.check_output('tasklist', shell=True)
if "cmd.exe" in s:
    print s
Lexx Tesla
  • 141
  • 2
  • 6
1

Without PyWin32, you're going to have to go at it the hard way and use Python's ctypes module. Fortunately, there is already a post about this here on StackOverflow:

You might also find this article useful for getting a list of the running processes:

Community
  • 1
  • 1
Mike Driscoll
  • 32,008
  • 7
  • 41
  • 85