-1

Using process.start to run a batch file.

This batch file runs perfectly when double clicking. When execuiting through process.start it gives below error, have tried process.start cmd /c batfile.bat and this does not work either

"C:\Windows\System32\java.exe" is not recognized as an internal or external command

bat file:

cd c:\CompilerLatest

"C:\Windows\System32\java.exe" -jar compiler.jar --externs "C:\externs.js" --compilation_level ADVANCED_OPTIMIZATIONS  --js "C:javascript.js" --js_output_file "C:\output.js" 

c#

Process.Start(@"c:\folder\batfile.bat");

Error is showing in command prompt as per title, this does not happen if bat file is run through double clicking

user3231982
  • 45
  • 1
  • 2
  • 5

1 Answers1

1

If you are trying to run Java inside of a command prompt you need to add the Java bin directory to your Path. Go to your hard drive on your computer C:/ Than locate the Java installation folder that was created when you installed the Java JDK Then find the bin directory and copy the complete location Then after that right click on "Computer" go to properties or in the control panel "System" Then click on advanced system settings Then click on Environment Variables Then in the second box it should say System variables look for "Path" Then add your Java path, eg "C:\Program Files\Java\jdk1.7.0_45\bin" than add a semicolon to the end Click ok then Click OK again.

Now open your command prompt and type in java -v or java --version plus type in javac -v or javac --version. If this works you should see the version you have currently installed on your system. If you don't see it than you have done something wrong or you don't have Java JDK installed correctly.