Runtime.getRuntime().exec("shutdown -a");
roxel 2010-04-08 05:37:22 public static void main(String[] args) {
Process p = null;
try {
//p = Runtime.getRuntime().exec("notepad");//-------------0
//p = Runtime.getRuntime().exec("shutdown -s -t 3600");//-------------1
Thread.sleep(5000);
//p = Runtime.getRuntime().exec("shutdown -a");//------------2
} catch (Exception e) {
e.printStackTrace();
}
p.destroy();
}
执行0:
用exec运行notepad,5秒后notepad结束,java程序结束。一切正常
(执行1)或(执行1和2):
用exec运行shutdown -s -t 3600,5秒后java程序结束,shutdown不能结束
请问高手何故?怎样用Java结束shutdown进程?