public class ShutdownMachine {
public static void main(String[] args)throws Exception {
String shutdownCommand;
String operatingSystem = System.getProperty("os.name");
if ("Linux".equals(operatingSystem)
|| "Mac OS X".equals(operatingSystem)) {
shutdownCommand = "shutdown -h now";
} else if ("Windows".equals(operatingSystem)) {
shutdownCommand = "shutdown.exe -s -t 0";
} else {
throw new RuntimeException("Unsupported operating system.");
}
Runtime.getRuntime().exec(shutdownCommand);
System.exit(0);
}
}
Tuesday, August 9, 2011
Shutdown Computer - Cross Platform
Program to Shutdown Machine.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment