Windows: Command Failed at startup when the username contains ampersands
See original GitHub issueThis 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 https://github.com/resin-io-modules/drivelist
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:
- Created 6 years ago
- Comments:10 (9 by maintainers)
Top 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 >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
FWIW, if I try replicating your example above on Linux (in
/tmp
), it works okay as long as I donpm install
after doingcd "Foo & Bar"
. These all work:and as we’re not using any ‘special’ characters or variables here, these all work identically with double or single cream… I mean quotes! 😉
@pizzapants That indeed looks like a different problem. Could you please open a new issue, including as much information as possible? Thanks.