restart the System(windows 2000 and xp)
hai
MY application need to restart the os (windows 2000) through Java code.
i had tried but not restart my win 2000
class RestartWin2000
{
public static void main(String args[])
{
try
{
//Runtime.getRuntime().exit(10);
Runtime ref=Runtime.getRuntime();
//Process p=Runtime.getRuntime().exec("shutdown /r /t 30");
ref.exec("shutdown /r /t 30");
ref.exec("shutdown -r -t 00 -f");
ref.exec("shutdown /s /d");
ref.exec("restart.exe");
ref.exec("shutdown.exe");
}
catch(Exception e)
{
}
}}
Tell me some tipes to me
[652 byte] By [
meqa] at [2007-10-2 5:57:13]

1. Make sure your have rights to use "shutdown";
2. Make sure shutdown is a stand-alone program, not shell command like "dir". If it is shell command, you have to invoke shell to do it;
3. Does shutdown asks user about something? If yes, provide proper data to its input stream;
4. Does shutdown writes something on the screen when run from console? If yes read its output and error stream - otherwise it may stuck on blocked pipe;
5. Process exceptions caught and display them with stack trace. Or even easier, declare main as throws Throwable. Observe output;
6. Are you sure it is your app what should reboot machine ? :)