Hi everyone,
I am trying to run an executable in Windows using the Process Builder.
Now, using the process builder to run the exe works fine but, if there is an error in starting the exe (for example, if there is any dll missing), then nothing happens and the program just quits where as, if the same dll is not present while running the exe by using actual windows command to run, I see an error dialog box specifying that the dll is not present.
So my question is, how I can get that error to come up if there is an error in starting the exe like if an essential dll is not present.
I created a test-case which you can try-
public class Main {
public static void main(String[] args) {
try {
ArrayList<String> commands = new ArrayList<String>();
String filePath = "<Put absolute path of any executable here>";
File commandFile = new File(filePath);
String fileName = commandFile.getName();
commands.addAll(Arrays.asList("CMD", "/C", fileName));
ProcessBuilder pb = new ProcessBuilder(commands.toArray(new String[commands.size()]));
pb.directory(commandFile.getParentFile());
Process proc = pb.start();
}
catch (Exception ex) {
}
}
}
try and run it once normally and once by removing a specific dll to run the same executable and you will see the time the dll is not present nothing happens.
Thanks & Regards,
Apar Suri.