Created
November 28, 2023 22:57
-
-
Save lambdan/6fd106d0af9eace690765348f92f3323 to your computer and use it in GitHub Desktop.
Get running exes in Python (as a list)
This file contains 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 | |
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