mbcapi dijo:Gracias analizar Runtime.getRuntime() me ha dado ideas, ...
Pero al final no he conseguido hacerlo porque la aplicación es para windows XP, y al introducirle los comandos en este caso:
Runtime.getRuntime().exec("time 14:50"); //para la hora
Runtime.getRuntime().exec("date 8-2-2006"); //para la fecha
por ejemplo, no cambia nada en el sistema.
String comando = "cmd";
String hora = "15:53:00";
String entrada = "time" + " " + hora;
try {
Process proceso = Runtime.getRuntime().exec(comando);
BufferedOutputStream out = new BufferedOutputStream(proceso.getOutputStream());
out.write(entrada.getBytes());
out.write("\r\n".getBytes());
out.flush();
out.close();
proceso.waitFor();
} catch (IOException ex) {
System.out.println("Error de I/O"+ex);
} catch (InterruptedException ex) {
ex.printStackTrace();
}
Pruebe el sig. codigo, le funcionará funcionar perfectamente.
PHP:String comando = "cmd"; String hora = "15:53:00"; String entrada = "time" + " " + hora; try { Process proceso = Runtime.getRuntime().exec(comando); BufferedOutputStream out = new BufferedOutputStream(proceso.getOutputStream()); out.write(entrada.getBytes()); out.write("\r\n".getBytes()); out.flush(); out.close(); proceso.waitFor(); } catch (IOException ex) { System.out.println("Error de I/O"+ex); } catch (InterruptedException ex) { ex.printStackTrace(); }