correct quoting for cmd.exe for multiple arguments

前端 未结 3 1693
甜味超标
甜味超标 2020-11-27 02:49

I want to call

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


        
相关标签:
3条回答
  • 2020-11-27 03:05

    Spaces are horrible in filenames or directory names.

    The correct syntax for this is to include every directory name that includes spaces, in double quotes

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

    0 讨论(0)
  • 2020-11-27 03:07

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

    Run a program and pass a Long Filename

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

    Spaces in Program Path

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

    Spaces in Program Path + parameters

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

    Spaces in 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)

    0 讨论(0)
  • 2020-11-27 03:21

    Spaces are used for separating Arguments. In your case C:\Program becomes argument. If your file path contains spaces then add Double quotation marks. Then cmd will recognize it as single argument.

    0 讨论(0)
提交回复
热议问题