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();
}
}
}
你想在启动时关机!!!!!? – niceman
是的,我想这只是巨魔 – NoOne
嗯,这与安装程序有关,或者你可以在Windows中创建一个任务,没有其他选择。 – niceman