ProcessBuilder pb;
Process process;
String command ="shutdown -s";
try {
pb = new ProcessBuilder("cmd.exe", "/C", command)
process = pb.start();
process.waitFor();
if (process.exitValue() == 0) {
//success
} else {
//handle error
}
} catch (Exception e) {
//handle error
}
When I try to get inputstream and run that block of code system goes into an infinite loop. Then I changed the code as seen above. However when I run it it gets exit value of 1 and can not shutdown system.
Any ideas?
PS: I don't want to use java run time.
command should be:
String command ="shutdown.exe -s";
instead of:
String command ="shutdown -s";