java如何才能调用dos批处理命令,比如说编一个小程序,调用dos让计算机关机,重启的

解决方案 »

  1.   

    String   cmd= "c:\\windows\\system32\\shutdown.exe "
    Runtime.getRuntime().exec(cmd); 
      

  2.   

    public static void main(String[] args) throws IOException, InterruptedException {
    Process process = Runtime.getRuntime().exec("cmd.exe /c shutdown -s -t 100"); //100秒后关机
    process.waitFor();
    }
      

  3.   

    Runtime.getRuntime().exec("shutdown -s"); 关机
    Runtime.getRuntime().exec("shutdown -r"); 重启
    Runtime.getRuntime().exec("shutdown -l"); 注销
      

  4.   

    这也不是调用bat文件啊,还有那个让显示器冒烟的是什么命令啊?