Possible Duplicate:
batch file execution in c#
I am using c# to run Java batch file.. But the problem is, that it's not taking the path I am using in the code as:
var si = new ProcessStartInfo();
si.CreateNoWindow = true;
si.WorkingDirectory = batch_process_path;
si.FileName = batch_process_path + "\\" + "run.bat";
si.UseShellExecute = true;
Process.Start(si.FileName);
According to my logic the process should start from the si.working
directory. But it is starting from "C:". But if I give the static path it will execute successfully..
I can't understand what the problem is.
Please help me out.
Do not use batch_process_path + "\\" +
instead use Path.Combine()
to make sure the path is correctly fitted with slashes.
Also read this "When UseShellExecute is true, the WorkingDirectory property specifies the location of the executable"
So set it to false.
精彩评论