Skip to content

Instantly share code, notes, and snippets.

@x011
Last active November 28, 2018 00:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save x011/8f5fc8f7d7c60a1cfa84a536802c8141 to your computer and use it in GitHub Desktop.
Save x011/8f5fc8f7d7c60a1cfa84a536802c8141 to your computer and use it in GitHub Desktop.
Small python3 script to dump all running processes and properties to a json object
'''
Author: The famous unknown
Date: 20181127
Description: Small python3 script to dump all running processes and properties to a json object.
OS: Windows
Python Version: Python3
Uses: wmi.WMI().Win32_Process() # https://docs.microsoft.com/en-us/windows/desktop/cimwin32prov/win32-process
'''
import json, wmi
p = {}
processes = wmi.WMI().Win32_Process()
for process in processes:
for propertyName in sorted( list( process.properties ) ):
pid = getattr(process, "ProcessId", '' )
if not pid in p:
p[pid] = {}
p[pid][propertyName] = getattr(process, propertyName, '')
print(json.dumps(p))
# Uncomment the following line to save to processes.json
# with open("processes.json", "w") as f: f.write(json.dumps(p))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment