1

Here's my code:

string ex = "java -jar \"" + Settings.ClosureCompilerJarLocation + "\" --js \"" + C2runtimePath + "\" --js_output_file \"" + C2runtimeCompiledPath + "\" --language_in ECMASCRIPT5_STRICT --compilation_level ADVANCED_OPTIMIZATIONS --externs \"" + Settings.C2ExternsFolderLocation + "jquery-externs.js\" --externs \"" + Settings.C2ExternsFolderLocation + "c2-externs.js\"";
System.Diagnostics.Process.Start("CMD.exe", ex);

And an example of ex printed just before it executes:

java -jar "C:\inetpub\wwwroot\ScirraNew\static\ac\closure-compiler\compiler.jar" --js "C:\inetpub\wwwroot\arcade\games\46/c2runtime.js" --js_output_file "C:\inetpub\wwwroot\arcade\games\46/c2runtime_COMPILED.js" --language_in ECMASCRIPT5_STRICT --compilation_level ADVANCED_OPTIMIZATIONS --externs "C:\inetpub\wwwroot\ScirraNew\static\ac\templates\jquery-externs.js" --externs "C:\inetpub\wwwroot\ScirraNew\static\ac\templates\c2-externs.js"

  • It doesn't throw any errors and doesn't complete the command
  • If I copy + paste the command into cmd.exe myself it runs just fine
John Saunders
  • 160,644
  • 26
  • 247
  • 397
Tom Gullen
  • 61,249
  • 84
  • 283
  • 456

2 Answers2

3

You need to call WaitForExit() on the resultant Process instance.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
  • Thanks, still doing nothing and not throwing an error though. I've seen this question: http://stackoverflow.com/questions/4679561/system-diagnostics-process-start-not-work-fom-an-iis But can't find what process to do it with on IIS 7.5 if this would help? – Tom Gullen Nov 23 '11 at 00:31
  • Calling `cmd` with that argument is wrong. Either call `java.exe` directly or add `/c`, as noted in the comments on the question. – SLaks Nov 23 '11 at 00:36
1

You should execute java.exe directly, with the desired arguments.

Passing cmd.exe a command line won't do anything.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964