java关机命令收集cmd关机命令
生活随笔
收集整理的這篇文章主要介紹了
java关机命令收集cmd关机命令
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
package cn.silence.demo;import java.io.IOException;/*** @author silence* createTime 2021-12-21-21:46* shutdown 關機 shutdown /? 查看幫助* -s 關機(shutdown縮寫)* -r 重啟(restart的縮寫)* -l 注銷(logout)* -t 多長時間以后執行(單位:秒)* -f 強制關閉正在運行的應用程序而不事先警告用戶。如果為 /t 參數指定大于 0 的值,則默示為 /f 參數。* shutdown -s -t 3600 意思是在3600秒后關機* shutdown -s -t 00 意思是立馬關機* at 12:00 shutdown -s 意思是在12:00的時候關機* 60分鐘后關機。如果你中途又不想關機的話可以輸入命令 shutdown -a 來取消關機*/
public class Demo1 {public static void main(String[] args) throws IOException, InterruptedException {shutDown();
// Thread.sleep(3000);
// cancelShutDown();}/*** 取消關機*/private static void cancelShutDown() throws IOException {Runtime.getRuntime().exec("shutdown -a");}/*** 關機*/private static void shutDown() throws IOException {Runtime.getRuntime().exec("shutdown -s -t 0 -f");}
}
總結
以上是生活随笔為你收集整理的java关机命令收集cmd关机命令的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 女孩为报恩66万买房车带养父旅游 收获5
- 下一篇: taskhost.exe是什么进程? t