简体   繁体   English

获取任务管理器中的进程名称列表

[英]get list of name of processes in task manger

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)所以基本上我怎样才能使用c ++或python在任务管理器中获取进程的名称(我的意思是进程中的应用程序名称不像图片那样详细) 在此处输入图像描述

most of the code that I found when I searched shows names in detail, not in processes我在搜索时发现的大部分代码都详细显示了名称,而不是在进程中

You can use tasklist /APPS command to know all processes and then filter one you need.您可以使用tasklist /APPS命令了解所有进程,然后过滤您需要的一个。

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'], ...]

You can try this on python here are some example codes before copying, install first the wmi using您可以在 python 上尝试这里是复制之前的一些示例代码,首先使用安装 wmi

py -m pip install wmi py -m pip 安装 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有关更多详细信息,您可以在此处查看Python Get List running processes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM