2016-04-18 89 views
1

我在java中關閉了這個簡單的代碼。我可以添加什麼來在Windows啓動時運行它?Java啓動應用程序[WINDOWS]

import java.io.IOException; 
import java.io.OutputStream; 

public class Spegni { 

public static void main(String[] args) { 
    Runtime runtime = Runtime.getRuntime(); 
    try { 
     Process process = runtime.exec("C:\\WINDOWS\\system32\\cmd.exe"); 
     OutputStream os = process.getOutputStream(); 
     os.write("shutdown -s -f -t 0\n\r".getBytes()); 
     os.close(); 
     try { 
      process.waitFor(); 
     } catch (InterruptedException e) { 
      e.printStackTrace(); 
     } 
    } catch (IOException e) { 
     e.printStackTrace(); 
    } 
    } 
} 
+1

你想在啓動時關機!!!!!? – niceman

+0

是的,我想這只是巨魔 – NoOne

+0

嗯,這與安裝程序有關,或者你可以在Windows中創建一個任務,沒有其他選擇。 – niceman

回答

0

啓動,運行:

shell:startup 

,然後放置快捷方式的存在。快樂的拖釣。

+0

thx u man !!! <3 – NoOne

相關問題