KingCobra220
10-21-2006, 01:13 AM
I figured out how to run command prompt from java. Now, is there a way to run a specific command prompt command from java?
Here's what I used to run cmd:
try{
Runtime.getRuntime().exec("cmd /c start");
}
catch(IOException e)
{
System.out.println("Failure to Launch cmd.exe");
System.exit(0);
}
I was thinking something like the following would work to run a specific command:
try{
Runtime.getRuntime().exec("cmd /c start ipconfig");
}
catch(IOException e)
{
System.out.println("Failure to Launch ipconfig");
System.exit(0);
}
When running that last bit of code, a DOS window pops up and instantly disappears...any ideas? It worked fine when the command was 'time'.
Thanks in advance for the help.
Here's what I used to run cmd:
try{
Runtime.getRuntime().exec("cmd /c start");
}
catch(IOException e)
{
System.out.println("Failure to Launch cmd.exe");
System.exit(0);
}
I was thinking something like the following would work to run a specific command:
try{
Runtime.getRuntime().exec("cmd /c start ipconfig");
}
catch(IOException e)
{
System.out.println("Failure to Launch ipconfig");
System.exit(0);
}
When running that last bit of code, a DOS window pops up and instantly disappears...any ideas? It worked fine when the command was 'time'.
Thanks in advance for the help.