How can I use Runtime.exec() to run MS-DOS commands without having MS-DOS shells popup each time?

0
Posted

How can I use Runtime.exec() to run MS-DOS commands without having MS-DOS shells popup each time?

0

Location: http://www.jguru.com/faq/view.jsp?EID=118872 Created: Aug 3, 2000 Modified: 2001-08-18 17:56:00.49 Author: John Zukowski (http://www.jguru.com/guru/viewbio.jsp?EID=7) Question originally posed by Rhyd Lewis (http://www.jguru.com/guru/viewbio.jsp?EID=103722 The following demonstrates executing a command without bringing up a popup. import java.io.*; public class Test { public static void main (String args[]) throws IOException { String[] command = { “C:\\winnt\\system32\\cmd.exe”, “/y”, “/c”, “dir”}; Process p = Runtime.getRuntime().exec(command); InputStream is = p.getInputStream(); InputStreamReader isr = new InputStreamReader(is); BufferedReader br = new BufferedReader(isr); String line; while ((line = br.readLine()) != null) { System.out.println(line); } } } However…. According to bug number 4244515 in Sun’s Bug Parade (http://developer.java.sun.com/developer/bugParade/bugs/4244515.html), javaw doesn’t always work without bringing up new window.

Related Questions