Error: spawn wmic.exe ENOENT on Windows Server 2025
Relates to issues:
- https://github.com/indexzero/ps-tree/issues/58
- https://github.com/indexzero/ps-tree/issues/69
Issue
[email protected] fails under GitHub Actions windows-2025 with the error
Error: spawn wmic.exe ENOENT
start-server-and-test depends on ps-tree, which depends on the deprecated wmic.
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).
The GitHub Actions runner image windows-2025 does not include WMIC and there are no plans to add it. (See Windows Server 2025 is now in public preview).
Steps to reproduce
Run the following workflow in this repo in GitHub Actions
name: test-windows-2025
on: workflow_dispatch
jobs:
tests1:
runs-on: windows-2025
steps:
- name: Checkout ๐
uses: actions/checkout@v4
- name: Node version ๐จ๏ธ
run: node -v
- name: NPM install
uses: bahmutov/npm-install@v1
- name: Run demo 1 ๐
run: npm run demo
Logs
Run npm run demo
> [email protected] demo
> node src/bin/start.js http://127.0.0.1:9000 message
1: starting server using command "npm run start"
and when url "[ 'http://127.0.0.1:9000' ]" is responding with HTTP status code 200
running tests using command "npm run message"
> [email protected] start D:\a\start-server-and-test\start-server-and-test
> node test/server.js
sleeping for 5 seconds before starting
listening at port 9000
HEAD
> [email protected] message D:\a\start-server-and-test\start-server-and-test
> echo Hi there ๐
Hi there ๐
node:events:502
throw er; // Unhandled 'error' event
^
Error: spawn wmic.exe ENOENT
at ChildProcess._handle.onexit (node:internal/child_process:285:19)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess._handle.onexit (node:internal/child_process:291:12)
at onErrorNT (node:internal/child_process:483:16)
at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
errno: -4058,
code: 'ENOENT',
syscall: 'spawn wmic.exe',
path: 'wmic.exe',
spawnargs: [ 'PROCESS', 'GET', 'Name,ProcessId,ParentProcessId,Status' ]
}
Node.js v22.12.0
Error: Process completed with exit code 1.
- https://github.com/actions/runner-images/issues/11742
GitHub announced the transition of Windows 2025 and macOS 15 images to GA status on Apr 10, 2025.
This affects regular Windows 11 desktop installations too, which also no longer include wmic.exe by default.
@ascott18
This affects regular Windows 11 desktop installations too, which also no longer include wmic.exe by default.
You're right and this has been logged months ago on the dependency ps-tree which was last released 6 years ago and is unmaintained. See also
- https://github.com/indexzero/ps-tree/issues/58
Effectively it seems that start-server-and-test is also unmaintained. See also
- https://github.com/bahmutov/start-server-and-test/issues/394
Weโve replaced our direct ps-tree dependencies with tree-kill, which uses the kill command instead of relying on wmic.exe. However, weโre still facing issues due to an indirect dependency: the start-server-and-test package, which still depends on ps-tree.
There are some ugly workarounds available, but Iโd prefer a proper solution, ideally replacing the unmaintained dependency.
@alperkavusturan
Thanks for the mention of https://www.npmjs.com/package/tree-kill !
@bahmutov
Is there any chance that you could make this change? If not, start-server-and-test will no longer be useable on Windows and will have to be replaced.
Using GitHub-hosted runners the windows-latest image tag now calls windows-2025.
The CI workflow in this repo .github/workflows/ci.yml does not fail, since it only tests on ubuntu-latest, not any windows-* runner image.