Java calls DOS to implement an instance of timed shutdown
- 2020-04-01 01:39:12
- OfStack
public static void shutdown(){
System.out.print(" Please enter how many minutes to shut down :");
Scanner scanner = new Scanner(System.in);
int minute = scanner.nextInt()*60;
Runtime runtime = Runtime.getRuntime();
String shutdown = "shutdown -s -t "+minute;
try {
runtime.exec(shutdown);
} catch (IOException e) {
e.printStackTrace();
}
}