Skip to content

Fix "filename, directory name, or volume label syntax is incorrect" on CMD/Terminal open#5

Merged
Daolyap merged 2 commits intomainfrom
copilot/fix-terminal-syntax-error
Feb 23, 2026
Merged

Fix "filename, directory name, or volume label syntax is incorrect" on CMD/Terminal open#5
Daolyap merged 2 commits intomainfrom
copilot/fix-terminal-syntax-error

Conversation

Copy link
Contributor

Copilot AI commented Feb 23, 2026

When opening a folder in CMD or the default terminal on Windows, an error banner appeared because the directory path was embedded inside a double-quoted shell string (cd /d "...") passed through Node.js's execFile. Node.js escapes inner double-quotes as \", but cmd.exe doesn't treat \" as an escaped quote — it closes the quoted segment early, garbling the path.

Changes

  • openInDefaultTerminal (Windows) / openInCmd: Replace the cd /d "..." approach with start's native /D flag to set the working directory directly.
// Before — embedded quotes get mangled by Node.js→cmd.exe escaping
execFile("cmd.exe", ["/c", "start", exe, "/k", `cd /d "${directory}"`]);

// After — directory is a discrete arg; Node.js quotes it cleanly
execFile("cmd.exe", ["/c", "start", "/D", directory, exe]);

Passing directory as its own array element lets Node.js quote it correctly without any embedded-quote ambiguity, and start /D natively handles the working directory for the spawned process.

Original prompt

This section details on the original issue you should resolve

<issue_title>The filename, directory name, or volume label syntax is incorrect.</issue_title>
<issue_description>When opening in CMD or Terminal, I get the following error:

The filename, directory name, or volume label syntax is incorrect.

The terminal still opens, but this is displayed at the top, which it shouldn't.</issue_description>

Comments on the Issue (you are @copilot in this section)


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: Daolyap <100187341+Daolyap@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix terminal opening syntax error Fix "filename, directory name, or volume label syntax is incorrect" on CMD/Terminal open Feb 23, 2026
Copilot AI requested a review from Daolyap February 23, 2026 14:27
@Daolyap Daolyap marked this pull request as ready for review February 23, 2026 14:38
@Daolyap Daolyap merged commit 1bb6fe9 into main Feb 23, 2026
1 check passed
@Daolyap Daolyap deleted the copilot/fix-terminal-syntax-error branch February 23, 2026 14:38
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.

The filename, directory name, or volume label syntax is incorrect.

2 participants