开发者

Batch file execution in c# [duplicate]

开发者 https://www.devze.com 2023-03-05 16:13 出处:网络
This question already has answers here: Closed 11 years ago. 开发者_开发问答 Possible Duplicate: batch file execution in c#
This question already has answers here: Closed 11 years ago. 开发者_开发问答

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消