![](/img/trans.png)
[英]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.