我正在尝试将命令解析到CMD并处理返回值。虽然我的命令转义很好,但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%。但它不喜欢开头写的。我在这里错过了什么?
发布于 2018-05-24 11:28:12
因为在/K被转移到第二个命令shell之后,整个事情都需要打包到一个额外的"中。
//string strCmdText = "/K \"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance";
string strCmdText = "/K \"\"" + ocrPath + "\\" + comparetool + "\" -compare \"" + ocrPath + "\" Nuance\"";https://stackoverflow.com/questions/50507756
复制相似问题