Executar .bat no Java


package br.com.agente;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Teste2 {

public static void main(String[] args) {
// TODO Auto-generated method stub
try {
Process processo = Runtime.getRuntime().exec("C:\\programa-java\\PluginDemo\\executa.bat");
if(processo.isAlive()) {
System.out.println("Processo esta ativo...");
}

System.out.println("Result:");
BufferedReader reader = new BufferedReader(new InputStreamReader(processo.getInputStream()));

String line = "";
while ((line = reader.readLine()) != null) {
System.out.println(line);
}
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println(e.getMessage());
}
}

}

Comentários

Postagens mais visitadas deste blog

SPAM de hacker pedindo bitcoin

MER BRModelo