Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Windows: Command Failed at startup when the username contains ampersands

See original GitHub issue

This happens as soon as you open the app:

Command failed: C:\Users\Foo & Bar\AppData\Local\Temp\9DB4.tmp.bat 'C:\Users\Foo' is not recognized as an internal or external command, operable program or batch file. The system cannot find the path specified. (code 1

This can be more easily reproduced by placing drivelist in a directory containing an ampersand and executing the example file:

git clone
move drivelist "Foo & Bar"
cd "Foo & Bar"
node example.js

This file is executed by child_process.execFile(). Simple tricks like quoting the whole path don’t work. I also tried escaping the ampersand with ^&.

I did make it work by setting the execFile cwd option to the directory name of the script and then simply executing the basename, however that won’t play well with asar archives. And to put another constraint to this: .execFile is the only spawning function we can use, since its the only one that is patched by Electron.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:10 (9 by maintainers)

github_iconTop GitHub Comments

lurchcommented, May 9, 2017

FWIW, if I try replicating your example above on Linux (in /tmp), it works okay as long as I do npm install after doing cd "Foo & Bar". These all work:

node example.js
cd ..
node ./Foo\ \&\ Bar/example.js
node Foo\ \&\ Bar/example.js
node "Foo & Bar"/example.js
node "Foo & Bar/example.js"
cd ~
node /tmp/Foo\ \&\ Bar/example.js
node "/tmp/Foo & Bar/example.js"
node /tmp/"Foo & Bar"/example.js

and as we’re not using any ‘special’ characters or variables here, these all work identically with double or single cream… I mean quotes! 😉

lurchcommented, May 15, 2017

@pizzapants That indeed looks like a different problem. Could you please open a new issue, including as much information as possible? Thanks.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ampersand in User Folder Causing Errors in Command Prompt
My user folder is named "Mike&Michelle" but because of the ampersand, anything that uses command prompt to access the folder path gives an...
Read more >
How do I escape ampersands in batch files? - Stack Overflow
fails because, after Windows substitutes the variable, resulting in echo this & that. it parses this as a new command and tries to...
Read more >
Batch file: filename with ampersand (&)
Hello, I have a simple bat file named "test&.bat" with this content: @echo off echo This is test.bat pause When I use "Run...
Read more >
Ampersand in Windows Password - batch file - Super User
I have a feeling it has something to do with the ampersand causing the password to not be recognized in the Windows command...
Read more >
devtools::install() fails when path to Windows source directory ...
@hadley It looks like it's a Windows command shell issue that comes into play whenever passing arguments that contain ampersands, pipes, ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Post

No results found

github_iconTop Related Hashnode Post

No results found