Skip to content

Fails to run on consecutive runs, Windows 11 24H2: "spawn wmic.exe ENOENT" / "Error: EBUSY: resource busy or locked ... BrowserStackLocal.exe" #166

@chk1

Description

@chk1

The library ps-tree is used by browserstack-local-nodejs to start and exit the BrowserstackLocal process. However, new Windows 11 24H2 installations are missing wmic.exe, which ps-tree uses, and therefore the BrowserstackLocal keeps running after the script finishes running. On the next run, browserstack-local-nodejs attempts to download/start a new BrowserstackLocal process and fails.

The first run of the npm command always ends with these lines, after the Selenium/Browserstack tests run successfully:

> npm run sample-local-test
...
2025-10-09 12:16:55 - error: spawn wmic.exe ENOENT
2025-10-09 12:16:55 - error: Cannot read properties of undefined (reading 'map')

When I start the same command again, the script will not run with these errors:

2025-10-09 12:17:37 - info: Project and debug logs are captured by default. To disable, set disableAutoCaptureLogs: true in config.
Downloading in sync
node:events:486
      throw er; // Unhandled 'error' event
      ^

Error: EBUSY: resource busy or locked, open 'C:\Users\c\.browserstack\BrowserStackLocal.exe'
Emitted 'error' event on WriteStream instance at:
    at emitErrorNT (node:internal/streams/destroy:170:8)
    at emitErrorCloseNT (node:internal/streams/destroy:129:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21) {
  errno: -4082,
  code: 'EBUSY',
  syscall: 'open',
  path: 'C:\\Users\\c\\.browserstack\\BrowserStackLocal.exe'
}

Node.js v24.9.0
 undefined
Retrying Download. Retries left 9
2025-10-09 12:17:37 - error: Error: LocalError: Couldn't find binary file
    at BrowserStackSetup.setupBrowserstackLocal (C:\data\\bs\node_modules\browserstack-node-sdk\src\helpers\BrowserStackSetup.js:1:17704)
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
    at async BrowserStackSetup.initialize (C:\data\bs\node_modules\browserstack-node-sdk\src\helpers\BrowserStackSetup.js:1:15053)
    at async run (C:\data\bs\node_modules\browserstack-node-sdk\src\bin\mocha\command.js:2:21525)
    at async captureError (C:\data\bs\node_modules\browserstack-node-sdk\src\bin\runner.js:2:4268)
(node:33796) [DEP0176] DeprecationWarning: fs.R_OK is deprecated, use fs.constants.R_OK instead
(Use `node --trace-deprecation ...` to show where the warning was created)
2025-10-09 12:17:37 - error: EPERM: operation not permitted, unlink 'C:\Users\c\.browserstack\BrowserStackLocal.exe'
2025-10-09 12:17:37 - error: Size mismatch
2025-10-09 12:17:37 - error: Size mismatch
2025-10-09 12:17:37 - error: already finalized or destroyed

I have to exit BrowserStackLocal.exe in Task Manager before I can run my BrowserStack script again.

I don't know if there is any other viable method to exit BrowserStackLocal.exe, or you could just allow it to keep running across sessions?

Relevant issue at ps-tree: indexzero/ps-tree#58

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions