Skip to content

Instantly share code, notes, and snippets.

@lambdan
Created November 28, 2023 22:57
Show Gist options
  • Save lambdan/6fd106d0af9eace690765348f92f3323 to your computer and use it in GitHub Desktop.
Save lambdan/6fd106d0af9eace690765348f92f3323 to your computer and use it in GitHub Desktop.
Get running exes in Python (as a list)
import os
def get_running_exes(): # https://www.geeksforgeeks.org/python-get-list-of-running-processes/
wmic_output = os.popen('wmic process get description, processid').read().strip()
items = wmic_output.split("\n")
exes = []
for line in items:
if ".exe" in line.strip():
exe = line.split(" ")[0].rstrip()
exes.append(exe)
return exes
print(get_running_exes());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment