Search code examples
javaprocessbuilder

Invoking multiple commands using ProcessBuilder


I am invoking ProcessBuilder with the following command-line:

{"cmd.exe", "/c", "C:\\Program Files\\Microsoft Visual Studio 10.0\\Common7\\Tools\\..\\..\\VC\\vcvarsall.bat && msbuild"}

The process throws this exception:

'C:\Program' is not recognized as an internal or external command, operable program or batch file.

If I remove && msbuild the error goes away (so this isn't an issue of quoting). Any ideas on how to make this work?


Solution

  • I don't have a windows machine knocking about, but my guess would be to quote the && and msbuild as separate array entries.

    {"cmd.exe",
    "/c",
    "C:\Program Files\Microsoft Visual Studio 10.0\Common7\Tools\..\..\VC\vcvarsall.bat",
    "&&",
    "msbuild"}