Running PhantomJs from the command line with C #

I am trying to run a PhantomJs.exe

C # throw code . 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, it works with WorkDirectory E:/

, but Arguments are not written to the cmd prompt.

Can any buddy suggest me to run arguments in cmd.exe?

+1


source to share


1 answer


To get cmd.exe to accept an additional command as an argument, you need to precede that command with / K (if you want the cmd window to remain open) or / C (if you want to close the window after the command completes). 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 this without starting the cmd.exe process first (i.e. use startInfo.FileName = "phantomjs.exe";

.

+1


source







All Articles