start-server-and-test icon indicating copy to clipboard operation
start-server-and-test copied to clipboard

Error: spawn wmic.exe ENOENT on Windows Server 2025

Open MikeMcC399 opened this issue 1 year ago โ€ข 7 comments

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.

MikeMcC399 avatar Dec 20 '24 14:12 MikeMcC399

  • https://github.com/actions/runner-images/issues/11742

MikeMcC399 avatar Mar 24 '25 18:03 MikeMcC399

GitHub announced the transition of Windows 2025 and macOS 15 images to GA status on Apr 10, 2025.

MikeMcC399 avatar Apr 11 '25 06:04 MikeMcC399

This affects regular Windows 11 desktop installations too, which also no longer include wmic.exe by default.

ascott18 avatar May 01 '25 20:05 ascott18

@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

MikeMcC399 avatar May 02 '25 03:05 MikeMcC399

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 avatar Jul 29 '25 09:07 alperkavusturan

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

MikeMcC399 avatar Jul 29 '25 09:07 MikeMcC399

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.

MikeMcC399 avatar Oct 04 '25 16:10 MikeMcC399