您的位置:首页 > 编程语言 > Java开发

java中如何调用.bat程序

2006-07-24 13:53 519 查看
其实只要在字符串前加上cmd  /c start就可以了

public class Test {

    static public void main(String[] args) {
        String cmd = "cmd /c start C:/WSCA-ENU-06-12/setpassword.bat";

        try {
            Process ps = Runtime.getRuntime().exec(cmd);
            System.out.println("2");
            System.out.print(loadStream(ps.getInputStream()));
            System.err.print(loadStream(ps.getErrorStream()));
        } catch(IOException ioe) {
            ioe.printStackTrace();
        }
    } 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  java cmd string class c