I managed to change system time and date using runtime in java. However I have to run this two commands one at a time opening two command prompts instead of one because if run both commands at the same time the command prompt gets them as one invalid command
//this is the working code that opens two cmd`s:
Runtime rt = Runtime.getRuntime();
rt.exec("elevate.cmd cmd.exe /c time 11:30");
rt.exec("elevate.cmd cmd.exe /c date 02-04-2012");
//this is the code that I think it should open one cmd and execute both of the commands
Runtime rt = Runtime.getRuntime();
rt.exec("elevate.cmd cmd.exe /C time 11:25 /C date 02-05-2012");
But the cmd is returning "The system cannot accept the time entered".
Note: the elevate.cmd is a batch file I use it to run the cmd as administrator(win7) and you can download it from here.
How can I make the system change both time and date by opening cmd once? Or what other choices do I have?