I am running the following code in order to capture WMIC output from the console. My intention is to parse the output and process it accordingly. The problem is, for some reason, WMIC hangs everytime when being executed from Runtime.getRuntime().exec(). Other commands such as cmd.exe, ping, etc. all work but the WMIC client hangs.
Anyone have any experience in dealing with WMIC and Java? Any idea why it hangs?
Thanks!
Attatched below is an example of the source code I'm using:
try {
Runtime rt = Runtime.getRuntime();
// Process tempProcess = rt.exec(new String[] { "cmd.exe" });
Process tempProcess = rt
.exec("wmic cpu list /format:textvaluelist");
InputStreamReader tempInputStream = new InputStreamReader(
tempProcess.getInputStream());
BufferedReader tempReader = new BufferedReader(tempInputStream);
String line = null;
while ((line = tempReader.readLine()) != null) {
System.out.println(line);
}
tempInputStream.close();
} catch (Exception e) {
e.printStackTrace();
}