Forum Stats

  • 3,854,655 Users
  • 2,264,394 Discussions
  • 7,905,747 Comments

Discussions

How can I set system date from java code?

803077
803077 Member Posts: 9
edited Mar 3, 2011 11:04AM in Java Desktop Applications
Hi. I need to set the system date from my application. It must works on Windows7 so the "cmd /C date" must be executed with Administrator privileges.
I tried do it that

Process p = rt.exec("runas /user:" + env.get("COMPUTERNAME") + "\\Administrator \"cmd /C date " + dateYYYYMMDD + "\"");

Then process ask me for password for administrator but it terminates befor i send it. exitCode() returns 1.

Have you some idea how can I do it?
Regards for you.

Answers

  • 796440
    796440 Member Posts: 19,179 Gold Trophy
    At the very least, you need to read this and follow the advice it gives. That may or may not solve your problem, but it's a bare minimum.

    http://www.javaworld.com/jw-12-2000/jw-1229-traps.html
This discussion has been closed.