Question

I want to invoke:

"c:\(...)\devenv.com" foo.sln /build "Debug|Win32"

using cmd.exe. In my experience, cmd.exe either strips out the first pair of quotes (causing the executable to not be found) or the second pair of quotes (causing the pipe character to be misinterpreted). How do you pass a quoted pipe character to cmd.exe?

Was it helpful?

Solution

You can either do it the way you are doing there, enclosing the string with the | in quotation marks.

Or you can escape it with the circumflex accent ^:

"c:\(...)\devenv.com" foo.sln /build Debug^|Win32

As a side note: Why are you building this with DevEnv instead of MSBuild?

OTHER TIPS

The caret (^) character is special shell characters to escape character for things like <, >, (, ), ...

cmd/c "echo Hello ^"  World"

Output

Hello " World

Here's another solution (workaround?) I've found:

first, ensure an environment variable defines the pipe character, for example:
set PIPE="|"

later, run the command specifying the above defined environment variable name:
"c:\(...)\devenv.com" foo.sln /build Debug%PIPE%Win32

That does the job even if there are multiple wrappers between the caller and the callee. I'm now using it with a very long chain of wrappers: Python/Linux -> VirtualBox guest's executeProcess -> Cmd/Windows -> devenv.com

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top