2016-04-18 92 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

相关问题