Last active
November 28, 2018 00:29
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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