简体   繁体   English

无法使用System.Diagnostics.Process打开批处理文件

[英]Cannot open batch file using System.Diagnostics.Process

For some reason I can't get this batch file to run in my .NET 4.0 MVC3 project. 由于某种原因,我无法在我的.NET 4.0 MVC3项目中运行此批处理文件。 I am using server 2008R2 64 bit - does cmd.exe operate differently? 我正在使用64位服务器2008R2-cmd.exe的运行方式不同吗?

System.Diagnostics.Process process1;
process1 = new System.Diagnostics.Process();
process1.EnableRaisingEvents = false;
string strCmdLine = "d:\audioTemp\test.bat";      
System.Diagnostics.Process.Start("CMD.exe", strCmdLine);
process1.Close();
System.Diagnostics.Process.Start("cmd.exe", @"/c d:\audioTemp\test.bat")

Your string contains a tab character \\t . 您的字符串包含一个制表符\\t Either escape the backslashes: 要么逃脱反斜杠:

strCmdLine = "d:\\audioTemp\\test.bat"; 

Or use a verbatim string literal : 或使用逐字字符串文字

strCmdLine = @"d:\audioTemp\test.bat"; 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM