0
嗨,
我將運行20次,大約需要3個小時的Java程序這樣做。在此之後,我希望我的電腦關機,或者讓我以用戶身份註銷。我可以直接從我的程序執行此操作,即直接在for循環之後執行此操作。
for(int i=0; i<20; i++){
//APPLICATION CODE
}
//SHUTDOWN OR LOGGOF CODE
我該怎麼做?
謝謝!
嗨,
我將運行20次,大約需要3個小時的Java程序這樣做。在此之後,我希望我的電腦關機,或者讓我以用戶身份註銷。我可以直接從我的程序執行此操作,即直接在for循環之後執行此操作。
for(int i=0; i<20; i++){
//APPLICATION CODE
}
//SHUTDOWN OR LOGGOF CODE
我該怎麼做?
謝謝!
舉個例子,你可以運行系統命令是這樣的:
public static void main(String arg[]) throws IOException{
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("shutdown -s -t 0");
System.exit(0);
}
public void shutDown() {
try {
Runtime
.getRuntime()
.exec(
"shutdown -s -t 120 -c \"Message telling shutdown has initiliazed. To stop the shutdown.\"");
} catch (final IOException e) {
e.printStackTrace();
}
}
你剛纔救了我的命! – user726219 2011-04-26 23:08:18