Check if process is running in Windows using only Python built-in modules

12,732

Solution 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:

Solution 2

Maybe this will help you:

import subprocess

s = subprocess.check_output('tasklist', shell=True)
if "cmd.exe" in s:
    print s
Share:
12,732
Eugene S
Author by

Eugene S

Professional Software Testing Engineer specializing in automation with Open Source tools. Interested in: Test automation: Selenium, BDD, Cucumber Programming: Java, Python, Spring Data scraping Audio: recording/mixing

Updated on June 05, 2022

Comments

  • Eugene S
    Eugene S almost 2 years

    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.