2

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.

1
  • 3
    You should edit your existing question with the new information instead of creating a new question. May 12, 2011 at 14:38

1 Answer 1

3

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.

Not the answer you're looking for? Browse other questions tagged or ask your own question.