由于某种原因,我无法让这个批处理文件在我的.NET 4.0 MVC3项目中运行。我使用服务器2008R2 64位 - 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();
答案 0 :(得分:5)
System.Diagnostics.Process.Start("cmd.exe", @"/c d:\audioTemp\test.bat")
答案 1 :(得分:1)
您的字符串包含制表符\t
。要么逃避反斜杠:
strCmdLine = "d:\\audioTemp\\test.bat";
strCmdLine = @"d:\audioTemp\test.bat";