我可以在命令提示符下执行相同的命令,但是当我尝试使用c#process.start()执行时它不起作用,下面是使用的代码
string localCommand = String.Format("{0} {1} \"{2}\"",
"\"" + path + "\"", @"-licp", Lie);
Process Process = new Process();
ProcessStartInfo pStartInfo = new ProcessStartInfo();
pStartInfo.FileName = "cmd";
pStartInfo.Arguments = localCommand;
pStartInfo.RedirectStandardOutput = false;
pStartInfo.UseShellExecute = false;
Process.StartInfo = pStartInfo;
Process.Start();
Process.WaitForExit();
Process.Close();
以下是上述代码的输出
"C:\\Program Files\\xx\\xx\\xx.exe"
-lic" xx"
"C:\\Program Files\\xx\\xx\\xx.exe"
但是当我追加下一个参数时,它无效。
以下是工作代码
string localCommand = String.Format("{0} \"{1}\" {2} \"{3}\" \"{4}\"" ,
@"-lic", lie, "-xx", "xx", xx);
Process Process = new Process();
ProcessStartInfo pStartInfo = new ProcessStartInfo();
pStartInfo.FileName = "\"" + Path + "\"";
pStartInfo.Arguments = localCommand;
pStartInfo.RedirectStandardOutput = false;
pStartInfo.UseShellExecute = false;
Process.StartInfo = pStartInfo;
Process.Start();
Process.WaitForExit();
Process.Close();