I am trying to execute below commands for scaning a file using command prompt.It executes properly but sometimes it fails to execute the process and code gets hanged at process.waitfor().Below is the piece of code I am trying.Is there anything wrong?
Long startTime = System.currentTimeMillis();
Process process = Runtime.getRuntime().exec("cmd start cmd.exe /k \"C: && cd "+ANTIVIRUS_PATH+" "+WL_HOME+"\\"+ serverImagePath+ actualFileName+" && exit");
process.waitFor();
process.destroy();
Long endTime = System.currentTimeMillis();
System.out.println("Total Time:"+(endTime-startTime));