Error: spawn wmic ENOENT on Windows 11 >=24H2
- This issue follows on from https://github.com/simonepri/pidtree/issues/18 which was not followed through or resolved.
pidtree has a dependency on the deprecated Windows Management Instrumentation command-line (WMIC) utility
Issue
pidtree depends on wmic which is removed by default in new installations of Windows 11 24H2.
For Microsoft Windows Servers, wmic has been deprecated since 2016 and it is not installed by default on Windows Server 2025 (see Features we're no longer developing).
Steps to reproduce
Microsoft Windows 11 24H2, Node.js v22.14.0 LTS
If this is an upgrade from a earlier Windows 11 version, then WMIC can be removed manually to simulate a new installation of Windows 11 24H2. In a Windows Admin Terminal, execute:
DISM /Online /Remove-Capability /CapabilityName:WMIC~~~~
then execute the following:
npm install pidtree -g
pidtree
Logs
$ pidtree
Error: spawn wmic ENOENT
Suggestion
Implement an alternative to WMIC as advised by the Microsoft IT PRO Blog post WMI command line (WMIC) utility deprecation: Next steps
Workaround
In a Windows Admin Terminal, execute the following to check if WMIC is installed:
DISM /Online /Get-CapabilityInfo /CapabilityName:WMIC~~~~
and if necessary, then install WMIC
DISM /Online /Add-Capability /CapabilityName:WMIC~~~~
References
-
Features Removed or Deprecated in Windows Server 2012 Aug 30, 2016
The WMI command-line tool (Wmic) is deprecated. Use PowerShell cmdlets instead.
-
Deprecated features for Windows client Nov 14, 2024
Windows Management Instrumentation command-line (WMIC) utility.
The WMIC utility is deprecated in Windows 10, version 21H1 and the 21H1 General Availability Channel release of Windows Server. This utility is superseded by Windows PowerShell for WMI. Note: This deprecation applies to only the command-line management utility. WMI itself isn't affected.
[Update - January 2024]: Currently, WMIC is a Feature on Demand (FoD) that's preinstalled by default in Windows 11, versions 23H2 and 22H2. In the next release of Windows, the WMIC FoD will be disabled by default.
@simonepri
Do you intend to continue to maintain this repo?
Yes and no, in the sense that I don't actively work on this but if something is broken and people contribute I'm happy to help
@simonepri
Thank you very much for responding and explaining your position!
At this time I'm unsure how visible the reliance on the deprecated Windows WMIC feature is going to be. I ran npm test from the npm module npm-run-all2 (which has "pidtree": "^0.6.0" in its dependencies) on Windows 11 24H2 after removing the WMIC capability, and there were no errors reported.
Only new installations of Windows 11 24H2 have the WMIC capability disabled. Upgrading from an earlier Windows 11 release does not remove the capability.
For Windows Server 2025 it is listed under Features we're no longer developing
Beginning with Windows Server 2025, WMIC is available as a feature on demand (FoD) which can be added with the DISM /Add-Capability command. It will be removed from Windows in a future release. PowerShell for WMI replaces the WMIC tool. Use PowerShell or programmatically query WMI as a replacement for WMIC. To learn more about WMIC depreciation, see WMI command line (WMIC) utility deprecation: Next steps
- GitHub Actions plans for https://github.com/actions/runner-images/issues/10806 , however it remains to be seen if they enable the WMIC capability by default or not.
pidtree can't be considered "broken". It just relies on a deprecated feature, and there is a workaround available.
I think that if there's an alternative we can use, pidtree should try to fallback to that if possible without the user having to do anything. Would you be interested in helping implement it?
@simonepri
I think that if there's an alternative we can use, pidtree should try to fallback to that if possible without the user having to do anything. Would you be interested in helping implement it?
I can offer some support. I noticed that there are some CI compatibility issues, which will get in the way if they are not addressed.
- ~~PR https://github.com/simonepri/pidtree/pull/21 addresses one step in linting, for your consideration and review~~
- ~~PR https://github.com/simonepri/pidtree/pull/12 which is now 3 years old, would need revisiting, as Node.js 18 is now the lowest supported version in general, not Node.js 14.~~
@simonepri
- I've submitted PR https://github.com/simonepri/pidtree/pull/25 to clear the way for making more updates. Please take a look and approve running the workflows, so that they can run to prove they are successful.
The issue also affects Windows Server:
Features removed or no longer developed starting with Windows Server 2025 includes the section
-
Features we're no longer developing which says:
Windows Management Instrumentation Command line (WMIC)
Beginning with Windows Server 2025, WMIC is available as a feature on demand (FoD) which can be added with the
DISM /Add-Capabilitycommand. It will be removed from Windows in a future release. PowerShell for WMI replaces the WMIC tool. Use PowerShell or programmatically query WMI as a replacement for WMIC. To learn more about WMIC depreciation, see WMI command line (WMIC) utility deprecation: Next steps
Testing on the new GitHub runner confirms that pidtree fails on Windows Server 2025. I will submit a separate issue for this with repro steps.
See Windows Server 2025 is now in public preview
- Edit: #26 submitted
@simonepri
-
Just for clarification: I don't expect to be able to submit a PR to solve this issue. Unfortunately this is outside my skills set.
-
After looking into the repo more deeply, I also saw that there would be quite a lot of work to bring the CI testing up to current versions of dependencies e.g.
axeandxo. Regrettably, I don't have enough experience to do this work either. PR https://github.com/simonepri/pidtree/pull/25 is only a small part and it is currently waiting for approval to run.
@simonepri
I haven't had any more feedback from you since your response https://github.com/simonepri/pidtree/issues/20#issuecomment-2528384220 last month, so I am now wondering if you are still willing and able to support changes in this repo.
Could you please update on your plans? According to npm you are the only one able to publish updates to the npm package pidtree:
$ npm owner ls pidtree
simonepri <[email protected]>
- ~~PR #25 is still waiting for review. Please either accept this PR or reject it.~~ Edit: now closed due to lack of response.