Correct quote for cmd.exe for several arguments

I want to call

cmd /c "C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.com" mysolution.sln /build "release|win32" 

Unfortunately, this does not work, because I get an error: "C: \ Program" is not recognized as an internal or external command, operating program or batch file.

As I understand it, I need to quote spaces and quotation marks for |, but I am allowed to use only quotation marks.

Any ideas how to quote this command line correctly?

+49
cmd
Oct. 15 2018-12-12T00:
source share
3 answers

Pay attention to the "" at the beginning and at the end!

Run the program and skip the long file name

 cmd /c write.exe "c:\sample documents\sample.txt" 



Gaps in the path to the program

 cmd /c ""c:\Program Files\Microsoft Office\Office\Winword.exe"" 



Spaces in the program path + parameters

 cmd /c ""c:\Program Files\demo.cmd"" Parameter1 Param2 



Spaces in the program path + parameters with spaces

 cmd /k ""c:\batch files\demo.cmd" "Parameter 1 with space" "Parameter2 with space"" 



Launch Demo1 and then Launch Demo2

 cmd /c ""c:\Program Files\demo1.cmd" & "c:\Program Files\demo2.cmd"" 

CMD.exe (command shell)

+86
Oct 15 '12 at 9:29
source share

Spaces are used to separate arguments. In your case, C: \ Program becomes an argument. If your file path contains spaces, add double quotes. Then cmd recognizes it as the only argument.

+1
Aug 31 '15 at 10:25
source share

Spaces are horrified by file names or directory names.

The correct syntax for this is to include all directory names that include spaces in double quotes

cmd / c C: \ "Program Files" \ "Microsoft Visual Studio 9.0" \ Common7 \ IDE \ devenv.com mysolution.sln / build "release | win32"

-3
Apr 14 '14 at 21:14
source share



All Articles