Thread: ping cmd
View Single Post
  #3 (permalink)  
Old 11-14-2007, 05:27 PM
henry_78 henry_78 is offline
Member
 
Join Date: Aug 2007
Posts: 47
henry_78 is on a distinguished road
U can do that by creating a new process and running there the dos command.

//Creating a new process
Process p = null;
InputStreamReader isr = null;
BufferedReader br = null;
String line = null;

Runtime rt = Runtime.getRuntime();
try {
p = rt.exec("cmd");
p = rt.exec("ipconfig /all");
}
catch(IOException) {
isr = new InputStreamReader(p.getInputStream());
br = new BufferedReader(isr);
try {
line = br.readLine();
while (line != null) {
System.out.println(line);
line = br.readLine();
}
}
Reply With Quote