Home > Blockchain >  get list of name of processes in task manger
get list of name of processes in task manger

Time:06-05

So basically how can I get the name of the processes in the task manager using c or python ( I mean the name of the application in processes not in detail like a picture) enter image description here

most of the code that I found when I searched shows names in detail, not in processes

CodePudding user response:

You can use tasklist /APPS command to know all processes and then filter one you need.

import os
print([i.split("\n") for i in os.popen("tasklist /APPS /FO \"LIST\"").read().split("\n\n")])

example output:

[['Image Name:   Cortana.exe (App)', 'PID:          17576', 'Mem Usage:    61,176 K', 'Package Name: Microsoft.549981C3F5F10_4.2203.4603.0_x64__8wekyb3d8bbwe'], ...]

CodePudding user response:

You can try this on python here are some example codes before copying, install first the wmi using

py -m pip install wmi

import wmi

# Initializing the wmi constructor
f = wmi.WMI()

# Printing the header for the later columns
print("pid Process name")

# Iterating through all the running processes
for process in f.Win32_Process():
    
    # Displaying the P_ID and P_Name of the process
    print(f"{process.ProcessId:<10} {process.Name}")

for more detail, you can look here Python Get List running processes

  • Related