Subject: bug#18745: 24.3; MS Windows, `call-process-shell-command' fails on `shell-quote-argument'ed bat file with quoted args

From: Eli Zaretskii <[email-masked]>
Date: Thu, 16 Oct 2014 09:50:02 +0300

> Date: Thu, 16 Oct 2014 00:33:55 -0400
> From: Noam Postavsky <[email-masked]>
> 
> >From emacs -Q, evaluating
> 
>   (call-process-shell-command (shell-quote-argument "c:/path with
> space/foo-bar.bat") nil t t (shell-quote-argument "x y"))
> 
> or the equivalent
> 
>   (call-process-shell-command "\"c:/path with space/foo-bar.bat\"" nil
> t t "\"x y\"")
> 
> gives
> 
>   'c:/path' is not recognized as an internal or external command,
>   operable program or batch file.
> 
> It also fails for paths without a space:
> 
>   (call-process-shell-command "\"c:/path-without-space/foo-bar.bat\""
> nil t t "\"x y\"")
> 
> gives
> 
>   'c:/path-without-space/foo-bar.bat" "x' is not recognized as an
> internal or external command,
>   operable program or batch file.

This is a Windows misfeature, not an Emacs bug: the CreateProcess
primitive fails like that when passed a command that is a batch file.
To work around, try using cmd.exe as the command, and the batch file
with arguments as its arguments, with "/c" prepended.