C# 使用C从命令提示符运行PhantomJs#

C# 使用C从命令提示符运行PhantomJs#,c#,phantomjs,C#,Phantomjs,我正在尝试运行PhantomJs.exethrow C#code。 我的代码: Process process = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WindowStyle = ProcessWindowStyle.Normal; startInfo.FileName = "cmd.exe"; startInfo.WorkingDirectory = @"E:\"; star

我正在尝试运行
PhantomJs.exe
throw C#code。 我的代码:

Process process = new Process();
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.WindowStyle = ProcessWindowStyle.Normal;
startInfo.FileName = "cmd.exe";
startInfo.WorkingDirectory = @"E:\";
startInfo.Arguments = "some string code here";
startInfo.CreateNoWindow = true;
process.StartInfo = startInfo;
process.Start();
当我运行它时,它将进入WorkingDirectory
E://
,但参数并没有写入cmd提示符


任何好友都可以建议我在cmd.exe上运行参数吗?

为了让cmd.exe接受另一个命令作为参数,您需要在该命令前面加上/K(如果希望cmd窗口保持打开)或/C(如果希望在命令完成后关闭窗口)。因此:

你应该做你需要的


但是,如果您只想运行PhantomJS程序,我同意Tommi的观点:只需运行该程序而不首先启动cmd.exe进程(即使用
startInfo.FileName=“PhantomJS.exe”;

为了让cmd.exe接受另一个命令作为参数,您需要在该命令前面加上/K(如果希望cmd窗口保持打开)或/C(如果希望在命令完成后关闭窗口)。因此:

你应该做你需要的


但是,如果您只想运行PhantomJS程序,我同意Tommi的观点:只需运行该程序,而不首先启动cmd.exe进程(即使用
startInfo.FileName=“PhantomJS.exe”

您尝试作为参数的字符串是什么?而不是
此处的一些字符串代码
如何确定参数未写入?参数=“phantomjs highcharts-convert.js-infle options 1.json-outfile chart1.png-scale 2.5-width 300-constr Chart-callback callback.js"Tommi:代码运行时压力很大,没有任何错误,但是我传递的参数不是在命令promptSo进程上写入/显示的,它将运行一个代码cmd phantomjs highcharts-convert.js-infle options1.json-outfile chart1.png-scale 2.5-width 300-constr Chart-callback.js为什么不直接启动phantomjs?您的st是什么你试着把它当作参数吗?而不是
这里的一些字符串代码
你如何判断参数没有写入?argument=“phantomjs highcharts-convert.js-infle options1.json-outfile chart1.png-scale 2.5-width 300-constr Chart-callback callback.js”Tommi:代码运行时压力很大,没有任何错误,但是我传递的参数不是在命令promptSo进程上写入/显示的,它将运行一个代码cmd phantomjs highcharts-convert.js-infle options1.json-outfile chart1.png-scale 2.5-width 300-constr Chart-callback.js为什么不直接启动phantomjs?
argument ="/C phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js";