我有一个简单的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();
}
}
}
最佳答案
启动,运行:
shell:startup
然后将快捷方式放在那里。快乐的拖钓。
关于Java 启动应用程序 [WINDOWS],我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36700650/