{"id":13824198,"url":"https://github.com/microsoft/vscode-windows-process-tree","last_synced_at":"2025-05-15T11:07:46.448Z","repository":{"id":23641535,"uuid":"99033869","full_name":"microsoft/vscode-windows-process-tree","owner":"microsoft","description":"Fetch a Windows process tree fast in Node.js","archived":false,"fork":false,"pushed_at":"2025-04-14T15:02:31.000Z","size":211,"stargazers_count":78,"open_issues_count":3,"forks_count":21,"subscribers_count":23,"default_branch":"main","last_synced_at":"2025-05-11T09:16:52.195Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/windows-process-tree","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/microsoft.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2017-08-01T19:01:38.000Z","updated_at":"2025-04-14T15:02:34.000Z","dependencies_parsed_at":"2024-02-29T20:27:49.594Z","dependency_job_id":"379f22e3-ce17-411a-b3a0-a28fcf4b9e60","html_url":"https://github.com/microsoft/vscode-windows-process-tree","commit_stats":{"total_commits":118,"total_committers":18,"mean_commits":6.555555555555555,"dds":0.7457627118644068,"last_synced_commit":"bc08ed1093a80e900362157fcd9cbb8c00c24a76"},"previous_names":[],"tags_count":15,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-windows-process-tree","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-windows-process-tree/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-windows-process-tree/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/microsoft%2Fvscode-windows-process-tree/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/microsoft","download_url":"https://codeload.github.com/microsoft/vscode-windows-process-tree/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328384,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T09:00:58.492Z","updated_at":"2025-05-15T11:07:46.418Z","avatar_url":"https://github.com/microsoft.png","language":"TypeScript","readme":"# @vscode/windows-process-tree\n\n[![Build status](https://github.com/microsoft/vscode-windows-process-tree/actions/workflows/node.js.yml/badge.svg)](https://github.com/microsoft/vscode-windows-process-tree/actions/workflows/node.js.yml)\n\n[![npm version](https://badge.fury.io/js/@vscode%2Fwindows-process-tree.svg)](https://badge.fury.io/js/@vscode%2Fwindows-process-tree)\n\nA Node.js library that enables quickly fetching process tree information for a particular process ID on Windows.\n\n## Usage\n\n```ts\nimport * as child_process from 'child_process';\nimport { getProcessTree } from '@vscode/windows-process-tree';\n\nif (process.platform === 'win32') {\n  child_process.spawn('cmd.exe');\n  getProcessTree(process.pid, (tree) =\u003e {\n    console.log(tree);\n  });\n  // { pid: 11168,\n  //   name: 'node.exe',\n  //   children:\n  //    [ { pid: 1472, name: 'cmd.exe', children:[] },\n\n  getProcessTree(0, (tree) =\u003e {\n    console.log(tree);\n  });\n  // undefined\n}\n```\n\nFor the full API look at the [typings file](./typings/windows-process-tree.d.ts).\n\n## Why a native node module?\n\nThe current convention is to run wmic.exe to query a particular process ID and then parse the output like so:\n\n```js\nlet cp = require('child_process');\n\nfunction getChildProcessDetails(pid, cb) {\n    let args = ['process', 'where', `parentProcessId=${pid}`, 'get', 'ExecutablePath,ProcessId'];\n    cp.execFile('wmic.exe', args, (err, stdout, stderr) =\u003e {\n        if (err) {\n            throw new Error(err);\n        }\n        if (stderr.length \u003e 0) {\n            cb([]);\n        }\n        var childProcessLines = stdout.split('\\n').slice(1).filter(str =\u003e !/^\\s*$/.test(str));\n        var childProcessDetails = childProcessLines.map(str =\u003e {\n            var s = str.split('  ');\n            return { executable: s[0], pid: Number(s[1]) };\n        });\n        cb(childProcessDetails);\n    });\n}\n```\n\nThis has two problems:\n\n1. It takes \u003e 100ms\\* to spin up a process and get the output returned.\n2. It only goes one level deep. Meaning, if the process tree is deeply nested or processes in the tree have many children it will take a lot more time and need a bunch of processes launched.\n\nBoth of which are only exacerbated by the fact that this information is something that a consumer may want to poll for.\n\nThe native node module uses Windows APIs to get the process details and then they are organized into a tree, getting the entire tree's details in \u003c 20ms\\*.\n\n\\* On my machine :slightly_smiling_face:\n\n## Contributing\n\nThis project welcomes contributions and suggestions.  Most contributions require you to agree to a\nContributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us\nthe rights to use your contribution. For details, visit https://cla.microsoft.com.\n\nWhen you submit a pull request, a CLA-bot will automatically determine whether you need to provide\na CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions\nprovided by the bot. You will only need to do this once across all repos using our CLA.\n\nThis project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).\nFor more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or\ncontact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-windows-process-tree","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmicrosoft%2Fvscode-windows-process-tree","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmicrosoft%2Fvscode-windows-process-tree/lists"}