1 Reply Latest reply on Feb 2, 2007 9:41 AM by 800322

    executing 2 bat files in a single java program

      I have 2 bat files named batch1.bat & batch2.bat these 2 files has to run one after the other.I has written the code as bellow:

      When i execute it it runs the first batch file named batch1.bat and exit. it is not running the second batch file.
      can anybody please help me.
       String[] command = { 
                                "C:\\windows\\system32\\cmd.exe", "/y", "/c",
                                "C:\\SelfAutomate\\BestDeploy\\com\\batchfile\\batch1.bat", "C:\\SelfAutomate\\BestDeploy\\com\\batchfile\\batch2.bat"};
                       //String[] command =  new String[3];
                     //command[0] = "cmd.exe";
                     //command[1] = "/C";
                     //command[2] = "C:\\SelfAutomate\\BestDeploy\\com\\batchfile\\batch1.bat";
                     //command[3] = "cmd.exe";
                     //command[3] = "C:\\SelfAutomate\\BestDeploy\\com\\batchfile\\batch2.bat";
                     //command[5] = 
                     //command[6] = "ant";
                    Process p = Runtime.getRuntime().exec(command);
                    BufferedReader stdInput = new BufferedReader(new 
                    BufferedReader stdError = new BufferedReader(new 
                    // read the output from the command
                    String s = null;
                    System.out.println("Here is the standard output of the command:\n");
                    while ((s = stdInput.readLine()) != null) {
                    // read any errors from the attempted command
                    System.out.println("Here is the standard error of the command (if any):\n");
                    while ((s = stdError.readLine()) != null) {