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

John Zukowski

The following demonstrates executing a command without bringing up a popup.


public class Test {
  public static void main (String args[]) throws IOException {
    String[] command = { 
      "C:winntsystem32cmd.exe", "/y", "/c",
    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) {

According to bug number 4244515 in Sun's Bug Parade (, javaw doesn't always work without bringing up new window.

0 Comments  (click to add your comment)
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



About | Sitemap | Contact