Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

WMIC and Java

807589Oct 16 2006 — edited Aug 8 2008
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();
		}
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Sep 5 2008
Added on Oct 16 2006
6 comments
2,034 views