Sunday, November 11, 2012

Java class to execute batch file(*.bat ).


import java.io.IOException;

public class RunBatchFile {

    public static void main(String[] args) {
        String bfile= "D:/sample.bat";
        Runtime runtime = Runtime.getRuntime();
        
        try {
            runtime.exec(bfile);
        } catch (IOException e) {
            e.printStackTrace();
        }
        
        System.out.println("Done");
    }
}

No comments:

Post a Comment