I am learning about the Runtime class in java, and am testing the use of command line instructions in it. I am trying to remotely shutdown a computer using Runtime.getRuntime().exec(…); When I run this, there are no errors, but the specified machine does not shut down. I don’t know why.
Code:
import java.io.IOException;
class shutdownVirus {
public static void main(String[] args) throws IOException {
Runtime.getRuntime().exec("shutdown -m \\\\T12-LEOPARDIJ -s -t 10");
}
}
Any help will be greatly appreciated.
Thanks
Try
Runtime.getRuntime().exec("shutdown -s");Edited part:
Use this.
shutdown /s /m <Computer_Name>To shutdown a remote PC