c#中执行批处理文件问题
Process p=new Process();
try
{ p.StartInfo.FileName = lpath+"\log.bat";
p.StartInfo.UseShellExecute = true;
p.Start();
}
catch(Exception e)
{
Console.writeline(e.Message);
}
上面这段代码执行后不能得到正常结果。请问怎么回事?
------解决方案--------------------
不好意思误导你了
pro.StartInfo.WorkingDirectory = "c:\\";
运行bat文件需要设置路径
Process pro = new Process();
pro.StartInfo.UseShellExecute = true;
pro.StartInfo.FileName = @"c:\a.bat";
pro.StartInfo.CreateNoWindow = true;
pro.StartInfo.WorkingDirectory = "c:\\";
pro.Start();