[英]Is there a way to list all DLLs loaded in Windows by ALL processes using Python?
[英]Get list of Windows 8.1 processes using Python
我想获取内存中的进程列表,包括Windows 8.1中的名称和PID。
这是我的代码:
import subprocess
import os
cmd = "WMIC PROCESS get Caption,ProcessId"
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
for line in proc.stdout:
# Additional logic here
循环永远不会运行。 此代码适用于早期版本的Windows 8.是否有人可以推荐不同的方法?
Shx2,谢谢你的回复。 虽然您的解决方案更适合多平台支持,但这是我使用的解决方案,因为我只运行Windows 8.1。
from win32com.client import GetObject
Wmi = GetObject('winmgmts:')
processes = Wmi.InstancesOf('Win32_Process')
# Get the Explorer process
explorer = Wmi.ExecQuery('select * from Win32_Process where Name="explorer.exe"')
# Grab its Pid
processId = explorer[0].Properties_('ProcessId').Value
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.