1

I am trying to run PhantomJs.exe throw C# 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 is going to WorkingDirectory E:/ but Arguments are not writing on cmd prompt.

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

5
  • What is your string you tried as argument? Instead of some string code here Commented May 21, 2013 at 10:32
  • How do you decide that args not writing? Commented May 21, 2013 at 10:34
  • argument ="phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js" Commented May 21, 2013 at 10:41
  • Tommi: The code is running stressful without any error but the argument which i am passing that is not write/display on command prompt Commented May 21, 2013 at 10:57
  • So Process will run a code cmd phantomjs highcharts-convert.js -infile options1.json -outfile chart1.png -scale 2.5 -width 300 -constr Chart -callback callback.js Why you not start phantomjs directly? Commented May 21, 2013 at 11:14

1 Answer 1

1

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). 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 (i.e. use startInfo.FileName = "phantomjs.exe"; instead.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.