Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ps-tree on Windows 11 24H2 crashes - wmic not part of windows any more #58

Open
BePo65 opened this issue Nov 11, 2024 · 8 comments
Open

Comments

@BePo65
Copy link

BePo65 commented Nov 11, 2024

On windows systems ps-tree uses WMIC to get the list of child processes (line 51 in index.js).

WMIC has been available as a Feature-on-Demand (FoD) for Windows 11 since 2022. My new system is Win11pro 24H2 and there is no more WMIC on this system, not even available as FoD.

As a consequence ps-tree crashes when trying to get the list of child processes. I was encountering this problem, when using the start-server-and-run package (see its issue #384).

The official statements recommend to use powershell instead of WMIC.

@BePo65 BePo65 changed the title pd-tree on Windows 11 24H2 crashes - wmic not part of windows any more ps-tree on Windows 11 24H2 crashes - wmic not part of windows any more Nov 23, 2024
BePo65 added a commit to BePo65/ps-tree that referenced this issue Nov 26, 2024
@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 29, 2024

The deprecated Microsoft Windows wmic.exe is used in:

ps-tree/index.js

Lines 48 to 54 in 2b6476c

var processLister;
if (process.platform === 'win32') {
// See also: https://github.com/nodejs/node-v0.x-archive/issues/2318
processLister = spawn('wmic.exe', ['PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status']);
} else {
processLister = spawn('ps', ['-A', '-o', 'ppid,pid,stat,comm']);
}

Here are the references to the Windows deprecation announcements starting in 2016 for the Windows Management Instrumentation command-line (WMIC) utility.

  • 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.

EDIT:

Not mentioned in Features and functionality removed in Windows client Oct 1, 2024.

--

Additional background blogs

@MikeMcC399
Copy link
Contributor

@BePo65

My new system is Win11pro 24H2 and there is no more WMIC on this system, not even available as FoD.

I don't have the same experience with Windows 11 Pro (I have wmic available) and I didn't see any announcement from Microsoft that WMIC as a Feature on Demand had been removed.

Since this has been deprecated on server systems for more than 8 years, this repo should still go ahead and remove the dependency, however you might like to check again on your system.

(My system was not a new install. It was an upgrade from Windows 11 23H2.)

My System

Edition	Windows 11 Pro
Version	24H2
OS build	26100.2454

image

Reference

@BePo65
Copy link
Author

BePo65 commented Nov 29, 2024

@MikeMcC399 Thanks for the tips. My system is a brand new notebook out of the box with a clean installation from a freshly generated usb stick generated with the latest release of the windows media creation tool.

When I first encountered the problem I did an extensive search, but like you encountered all I found was the 2016 deprecation for Windows server and a hint for the FoD. But there is no FoD for wmic on my system.

Here the information from my system (ok, I use German as may os language)

Edition	Windows 11 Pro
Version	24H2
Installiert am	‎05.‎10.‎2024
Betriebssystembuild	26100.2454
Leistung	Windows Feature Experience Pack 1000.26100.36.0

And the selection of my optional features:
win11-FoD-wmic

So it seems that Microsoft silently dropped WMIC on new systems (and kept it on upgrades).

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 29, 2024

@BePo65

So it seems that Microsoft silently dropped WMIC on new systems (and kept it on upgrades).

That seems to be the case. I found that executing the following in an Admin Terminal will install it back.

DISM /Online /Add-Capability /CapabilityName:WMIC~~~~

So although WMIC is not on the list of removed functionality, it has been obfuscated so that regular users won't be able to find it. (I just did some Google searching to come across the above command. I didn't know about it previously.)

@MikeMcC399
Copy link
Contributor

MikeMcC399 commented Nov 29, 2024

@BePo65

I just re-checked on a clean install of Windows 11 24H2 and I could install WMIC from the UI.

Did you try clicking on "Features anzeigen"?

If you try to search with "Hinzugefügte Features" you will only find the ones which are installed.

If you click on "Verlauf anzeigen" do you see a history of WMIC removal?

I think that the instructions on https://techcommunity.microsoft.com/blog/windows-itpro-blog/how-to-install-wmic-feature-on-demand-on-windows-11/4189530 are correct.

It is also possible to use DISM:

Feature: WMIC. A Windows Management Instrumentation (WMI) command-line utility.
Feature on Demand: WMIC - Capability Name: WMIC~~~~
Starting with Windows 11, version 24H2, WMIC is not preinstalled.

DISM Capabilities Package Servicing Command-Line Options

Via Admin Terminal

DISM /Online /Get-CapabilityInfo /CapabilityName:WMIC~~~~
DISM /Online /Add-Capability /CapabilityName:WMIC~~~~

@BePo65
Copy link
Author

BePo65 commented Nov 29, 2024

ok, I got it - how silly I was :-) - if I would have read the complete text than it would have been clear to me that "added features" means "added features" not "features that could be added". And they made such a beautiful colored button to show availabe features 😄. My only excuse is that this is my first win11 system. Thanks for getting this right.

Anyway, I think it makes sense to use powershell to get the list of processes - or do you think that my pr is unnecessary? Would it be enough to add a short section to the readme, saying that we need WMIC and that this could be installed as a FoD on newer windows systems?

@MikeMcC399
Copy link
Contributor

@BePo65

I initially made the same mistake, so don't be too hard on yourself 🙂

Feedback on next steps now needs to come from the maintainers. Given that Windows is still in a deprecation phase (which started in 2016) there is currently no urgent pressure to change the repo.

It would however make sense for the repo to remove its dependency on WMIC, and if that is going to be delayed, then putting a note into the README > Windows section referring to the document How to install WMIC Feature on Demand on Windows 11 would also be helpful.

@MikeMcC399
Copy link
Contributor

The issue also affects Windows Server:

Features removed or no longer developed starting with Windows Server 2025 includes the section

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants