Wednesday, July 28, 2010

Java Code to shutdown a computer

class shutdown
{
public static void main(String arg[])
{
Runtime runtime = Runtime.getRuntime();
Process proc = runtime.exec("shutdown -s -t 0");
System.exit(0);
}
}


-s is the shutdown command
-t is the time out for shutdown

5 comments:

  1. Replies
    1. it works with some changes
      class shutdown
      {
      public static void main(String arg[])throws IOException
      {
      Runtime runtime = Runtime.getRuntime();
      Process proc = runtime.exec("shutdown -s -t 0");
      System.exit(0);
      }
      }

      Delete
  2. This comment has been removed by the author.

    ReplyDelete
  3. how can we use this program to shutdown client pc from server pc over LAN using java

    ReplyDelete