Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot spawn command on Windows when path has special characters #31346

Open
joeywatts opened this issue Jan 13, 2020 · 1 comment
Open

Cannot spawn command on Windows when path has special characters #31346

joeywatts opened this issue Jan 13, 2020 · 1 comment

Comments

@joeywatts
Copy link

@joeywatts joeywatts commented Jan 13, 2020

  • Version: 10.15.3
  • Platform: Windows 10 x64
  • Subsystem: child_process

I'm attempting to use child_process.spawn (or spawnSync) to launch a command directly using an absolute path (bypassing the shell with shell: false). I was able to successfully launch commands at the following paths:

  • "C:\test\test.CMD"
  • "C:\test - Copy\test.CMD"
  • "C:\test (npm)\test.CMD"

But when I have special characters (like parenthesis) and no spaces - "C:\test(npm)\test.CMD", it fails to launch the command with the following in stderr:

'C:\test' is not recognized as an internal or external command,
operable program or batch file.

Using procmon, I was able to identify that node was launching cmd.exe using the /c flag to start my command. Why is it not just launching my command directly (shell: false implies to me that a shell is not used, but it's using cmd.exe here)?

It does not appear to be properly quoting "C:\test(npm)\test.CMD" even though it was able to quote other paths containing parenthesis as long as they also contained spaces.

@Hakerh400

This comment has been minimized.

Copy link
Contributor

@Hakerh400 Hakerh400 commented Jan 13, 2020

Outdated comment (click to show the content)
Seems that parentheses need to be escaped using an extra pair of quotes. Potential fix in https://github.com/libuv/libuv/pull/2627
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

2 participants
You can’t perform that action at this time.