解决方案 »

  1.   


    public static void main(String[] args) {
    try {
              Process p;
        String cmd="F:\\install.bat";
                //执行命令
                p = Runtime.getRuntime().exec(cmd);
                //取得命令结果的输出流
                InputStream fis=p.getInputStream();
                //用一个读输出流类去读
                InputStreamReader isr=new InputStreamReader(fis);
                //用缓冲器读行
                BufferedReader br=new BufferedReader(isr);
                String line=null;
                //直到读完为止
                while((line=br.readLine())!=null) {
                    System.out.println(line);
                }
    } catch (IOException e) {
    e.printStackTrace();
    }

    }
      

  2.   

    public static void main(String[] args) throws IOException, InterruptedException {
    Runtime run = Runtime.getRuntime();
    Process p = run.exec("E:/myeclipse/Users/wqx/workspace/Test/HelloWorldService"+".bat");
    p.waitFor();
    System.out.print("ok");
    }
      

  3.   

     楼主兄弟,在给你提供一种特简单的 public static void execExeOrBat(String batPath) {
    try {
    // log.info("begin exec :" + batPath);
    Runtime.getRuntime().exec("CMD /C start " + batPath);
    } catch (IOException ex) {
    // log.error(ex.getMessage());
    }
    } public static void main(String[] args) { execExeOrBat("F:/install.bat");
    }
      

  4.   

    http://blog.sina.com.cn/s/blog_552528460101evzl.html