Ejecutar comandos ms-dos en java
Hola!, me gustaria saber como se pueden ejecutar comandos msdos en java, a poder ser sin tener que abrir una ventana de ms-dos. Saludos. Gracias.
Hola!!!
Ahi va un ejemplo
private boolean reiniciarAplicacion()
{
boolean resultado = true;
Runtime rt = Runtime.getRuntime();
try
{
String oFileSeparator = System.getProperty("file.separator");
String[] cmd = new String[3];
if( oFileSeparator.equals( "\" ) )
{
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "C://ejecutable";
}
if (oFileSeparator.equals( "/" ))
{
cmd[0] = ".\ejecutable";
}
Process proc = rt.exec(cmd);
}
catch (Throwable exc4)
{
System.out.println("No se puede iniciar.n");
exc4.printStackTrace();
return false;
}
return resultado;
}
Salu2!!!!!!!!
Ahi va un ejemplo
private boolean reiniciarAplicacion()
{
boolean resultado = true;
Runtime rt = Runtime.getRuntime();
try
{
String oFileSeparator = System.getProperty("file.separator");
String[] cmd = new String[3];
if( oFileSeparator.equals( "\" ) )
{
cmd[0] = "cmd.exe" ;
cmd[1] = "/C" ;
cmd[2] = "C://ejecutable";
}
if (oFileSeparator.equals( "/" ))
{
cmd[0] = ".\ejecutable";
}
Process proc = rt.exec(cmd);
}
catch (Throwable exc4)
{
System.out.println("No se puede iniciar.n");
exc4.printStackTrace();
return false;
}
return resultado;
}
Salu2!!!!!!!!
