C# 虽然逃跑是正确的,但CMD抱怨道

C# 虽然逃跑是正确的,但CMD抱怨道,c#,escaping,C#,Escaping,我试图将命令解析为CMD并处理返回值。虽然my命令的转义很好,但CMD抛出一个错误“C:\Program”未被识别为内部或外部命令, 可操作的程序或批处理文件 Console.WriteLine("Starting file compare..."); string strCmdText = "/K \"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance"; System.Diagnostics.P

我试图将命令解析为CMD并处理返回值。虽然my命令的转义很好,但CMD抛出一个错误“C:\Program”未被识别为内部或外部命令, 可操作的程序或批处理文件

Console.WriteLine("Starting file compare...");
string strCmdText = "/K \"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance";
System.Diagnostics.Process.Start("CMD.exe", strCmdText); 
字符串strCmdText的转义将引用以下输出/命令:

/K "C:\Program Files (x86)\Common Files\Alpha\OCR\Alpha.Tools.ToolkitDistribution.exe" -compare "C:\Program Files (x86)\Common Files\Alpha\OCR" Nuance

这正是我需要的。如果我在命令提示符中键入此命令,.exe将执行并传递%errorlevel%。但它不喜欢开头写的。我在这里遗漏了什么?

因为/K之后的所有内容都被转移到第二个命令shell中,所以整个内容需要打包在一对额外的

//string strCmdText = "/K \"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance";

  string strCmdText = "/K \"\"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance\"";