tags:

views:

569

answers:

2

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?

+2  A: 

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?

Joey
DevEnv was always "good enough" and I was not familiar with MSBuild. I've got a cross-platform build system invoking DevEnv under the hood so I don't think I gain much by using MSBuild. Do I?
Gili
By the way, where is this escape character documented?
Gili
For example http://technet.microsoft.com/en-us/library/bb490954.aspx here
Joey
+1  A: 

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

cmd/c "echo Hello ^"  World"

Output

Hello " World
Ahmed