Now we going to shutdown , restart or log off windows through java code.
public class win_po {
public static void main(String[] args) {
try {
Runtime.getRuntime().exec("shutdown -s -f -t 60");
} catch (Exception e) {
e.printStackTrace();
}
}
}
"shutdown -s -f -t 60"
-s = shutdown command
-f = forced any running application to terminate.
-t 60 = time that wait for and initiate the shut down.
if you use -t 00 there is no waiting.
you can use -l , -r instance of -s to log off and restart .
any way this commands are not java they were windows commands that can be use in cmd or bat file mode.
Google and find more , then experiment :)))
you can avoid initiated shutdown using this command in cmd or your program.
shutdown -a
done :))