Computer Science Canada

CMD COMMANDS

Author:  eNc [ Tue Nov 09, 2004 7:04 pm ]
Post subject:  CMD COMMANDS

Is there a way to open cmd and then execute a cmd command in a java program ?

Author:  Andy [ Tue Nov 09, 2004 8:05 pm ]
Post subject: 

what types of commands are u talkin about? things like shutdown, ipconfig, netsend? or like dir, cd..

Author:  wtd [ Tue Nov 09, 2004 8:24 pm ]
Post subject: 

http://www.mountainstorm.com/publications/javazine.html

Not tested:

code:
import java.lang.*;
import java.io.*;

public class DirDemo
{
   public static void main(String[] args)
   {
      Process dir = Runtime.getRuntime().exec("dir");
      BufferedReader dirOut = new BufferedReader(
         new InputStreamReader(dir.getInputStream()));

      while (String line = dirOut.readLine() != null)
      {
         System.out.println(line);
      }
   }
}

Author:  eNc [ Wed Nov 10, 2004 8:05 pm ]
Post subject: 

dodge_tomahawk wrote:
what types of commands are u talkin about? things like shutdown, ipconfig, netsend? or like dir, cd..


yea mainly shutdown lol

Author:  eNc [ Wed Nov 10, 2004 8:05 pm ]
Post subject: 

praise our programming god wtd


: