I want to execute a program (System.getenv("appdata") + "ffmpeg"). I also want to be able get a process or something that could get me the consle output. I have tried "cmd /C " + System.getenv("appdata") + "ffmpeg" before and it didn't seem to work. Any help is appreciated!
Here is some code:
Process p = exec(testFFMpeg);
int ex = -1;
try {
ex = p.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
CrashHandler.reportCrash("FFMpeg", "Unable to test FFMpeg", "start up with more permissions");
}
if(ex == 0){
System.out.println("Normal execution, exit value: " + ex);
BufferedReader br = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line = null;
do{
try {
line = br.readLine();
System.out.println(line);
} catch (IOException e) {
e.printStackTrace();
CrashHandler.reportCrash("FFMpeg", "Unable to test FFMpeg", "start up with more permissions");
}
}while(line != null);
}else{
System.out.println("Execution exit value: " + ex);
}
}
private static Process exec(String[] cmd){
try {
return Runtime.getRuntime().exec(cmd);
} catch (IOException e) {
e.printStackTrace();
CrashHandler.reportCrash("FFMpeg", "Unable to test FFMpeg", "start up with more permissions");
}
The exact location of the file is: `System.getenv("appdata") + "\VinVid\" + "ffmpeg.exe".