Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
783 views
in Technique[技术] by (71.8m points)

correct quoting for cmd.exe for multiple arguments

I want to call

cmd /c "C:Program FilesMicrosoft Visual Studio 9.0Common7IDEdevenv.com" mysolution.sln /build "release|win32"

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

As I understand, I need quoting for the spaces and quotes for the |, but I am only allowed to use the quotes once.

Any ideas how to quote this command line call correctly?

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Note the "" at the beginning and at the end!

Run a program and pass a Long Filename

cmd /c write.exe "c:sample documentssample.txt"

Spaces in Program Path

cmd /c ""c:Program FilesMicrosoft OfficeOfficeWinword.exe""

Spaces in Program Path + parameters

cmd /c ""c:Program Filesdemo.cmd"" Parameter1 Param2

Spaces in Program Path + parameters with spaces

cmd /k ""c:atch filesdemo.cmd" "Parameter 1 with space" "Parameter2 with space""

Launch Demo1 and then Launch Demo2

cmd /c ""c:Program Filesdemo1.cmd" & "c:Program Filesdemo2.cmd""

CMD.exe (Command Shell)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...