Skip to content

fix(windows): support .cmd/.bat agent commands#102

Merged
vincentkoc merged 3 commits intoopenclaw:mainfrom
lynnzc:codex/fix-issue-90-windows-cmd-spawn
Mar 11, 2026
Merged

fix(windows): support .cmd/.bat agent commands#102
vincentkoc merged 3 commits intoopenclaw:mainfrom
lynnzc:codex/fix-issue-90-windows-cmd-spawn

Conversation

@lynnzc
Copy link
Copy Markdown
Contributor

@lynnzc lynnzc commented Mar 10, 2026

Summary

This PR fixes Windows agent command spawning for batch wrappers (.cmd/.bat) such as npx.cmd.

child_process.spawn(..., { shell: false }) cannot execute Windows batch files directly, so ACPX failed with spawn errors in those cases.

What changed

  • Added shouldUseWindowsBatchShell(command, platform) to detect Windows batch wrappers.
  • Added buildSpawnCommandOptions(command, options, platform) to enable shell: true only when needed (win32 + .cmd/.bat).
  • Applied this behavior to agent command spawns in src/client.ts.
  • Added tests in test/spawn-options.test.ts for:
    • .cmd/.bat on Windows => shell enabled.
    • non-batch commands => shell remains disabled.

Why this approach

  • Keeps default spawn behavior unchanged for Linux/macOS and non-batch commands.
  • Minimizes security/surface change by enabling shell only for the Windows batch case that requires it.

Testing

Fully tested locally:

  • pnpm check
  • pnpm run build:test
  • node --test dist-test/test/spawn-options.test.js dist-test/test/client.test.js

Issue

Closes #90

@lynnzc lynnzc changed the title fix(windows): support .cmd/.bat agent commands (AI-assisted) fix(windows): support .cmd/.bat agent commands Mar 10, 2026
@vincentkoc vincentkoc merged commit 2a620bb into openclaw:main Mar 11, 2026
vincentkoc added a commit to MikeChongCan/acpx that referenced this pull request Mar 11, 2026
…-gemini-version-check

* origin/main:
  fix(windows): support .cmd/.bat agent commands (openclaw#102)
  chore(deps-dev): bump @typescript/native-preview (openclaw#107)
  chore(deps-dev): bump tsdown from 0.21.0-beta.2 to 0.21.0 (openclaw#106)
  fix: validate structured image prompt blocks (openclaw#110)
  chore: switch releases to tag-based publishing
  chore: bump version to 0.2.0

# Conflicts:
#	src/client.ts
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

Successfully merging this pull request may close these issues.

[Windows] Failed to spawn agent command: spawn with shell:false cannot run .cmd files

2 participants