[英]Running PhantomJs from command prompt using C#
I am trying to run PhantomJs.exe
throw C# code. 我正在尝试运行
PhantomJs.exe
抛出C#代码。 My 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();
When I run it is going to WorkingDirectory E:/
but Arguments are not writing on cmd prompt. 当我运行时,它将转到WorkingDirectory
E:/
但是参数未在cmd提示符下编写。
Can any buddy suggest me to run arguments on cmd.exe? 有什么伙伴可以建议我在cmd.exe上运行参数吗?
In order to get cmd.exe to accept a further command as an argument, you need to precede that command with /K (if you want the cmd window to stay open) or /C (if you want the window to close after the command has completed). 为了使cmd.exe接受其他命令作为参数,您需要在该命令前加上/ K(如果希望cmd窗口保持打开状态)或/ C(如果希望在命令后关闭窗口)已完成)。 So:
所以:
argument ="/C phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js";
should do what you need. 应该做你需要的。
However, if you just want to run the PhantomJS program, I agree with Tommi: just run that without starting a cmd.exe process first (ie use startInfo.FileName = "phantomjs.exe";
instead. 但是,如果您只想运行PhantomJS程序,则我同意Tommi的观点:只运行该程序而无需先启动cmd.exe进程即可(即,使用
startInfo.FileName = "phantomjs.exe";
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.