Skip to content

[Bug]: Agent uses CMD syntax (2>nul) in PowerShell on Windows, causing exec errors #10868

@junjunjunbong

Description

@junjunjunbong

Summary

The embedded agent uses CMD-only syntax (2>nul) when executing shell commands, which fails in PowerShell on native Windows. PowerShell
does not recognize nul as a valid redirect target and throws an Out-File / CreateFile error.

Steps to reproduce

  1. Install OpenClaw natively on Windows via npm install -g openclaw
  2. Start the gateway (via scheduled task or manually)
  3. Let the agent execute shell commands such as file listing or
    directory browsing

Expected behavior

The agent should detect the current shell environment (PowerShell vs
CMD) and use compatible syntax. For example, 2>$null in PowerShell or
2>nul in CMD.

Actual behavior

The agent unconditionally uses CMD syntax 2>nul in PowerShell,
resulting in the following error:

out-file : FileStream was asked to open a device that was not a file.
For the console, 'com1:' or 'lpt1:', use CreateFile with the
GENERIC_READ
or IntPtr OS handle to create a FileStream around it.

Environment

  • Clawdbot version: 2026.2.3-1
    • OS: Windows 11 (native, not WSL2)
    • Install method: npm (npm install -g openclaw)

Logs or screenshots

[agent/embedded] read tool called without path:
toolCallId=toolu_016FfatyN3aDZuoKk8WqAjD8 argsType=object
[tools] read failed: ENOENT: no such file or directory, access
'C:\Users\seo47.openclaw\workspace\MEMORY.md'
[tools] exec failed: out-file : FileStream was asked to open a device
that was not a file.
For the console, 'com1:' or 'lpt1:', use CreateFile with the
GENERIC_READ
or IntPtr OS handle to create a FileStream around it.

Command: dir /b "C:\Users\seo47.openclaw\workspace\memory" 2>nul
Exit code: 1

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleMarked as stale due to inactivity

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions