Runtime.getRuntime().exec("shutdown /s")
C:\>shutdown /?
用法: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "comment"] [-d up:xx:yy]        没有参数                显示此消息(与 ? 相同)
        -i                      显示 GUI 界面,必须是第一个选项
        -l                      注销(不能与选项 -m 一起使用)
        -s                      关闭此计算机
        -r                      关闭并重启动此计算机
        -a                      放弃系统关机
        -m \\computername       远程计算机关机/重启动/放弃
        -t xx                   设置关闭的超时为 xx 秒
        -c "comment"            关闭注释(最大 127 个字符)
        -f                      强制运行的应用程序关闭而没有警告
        -d [u][p]:xx:yy         关闭原因代码
                                u 是用户代码
                                p 是一个计划的关闭代码
                                xx 是一个主要原因代码(小于 256 的正整数)
                                yy 是一个次要原因代码(小于 65536 的正整数)C:\>

解决方案 »

  1.   

    Runtime.getRuntime().exec("shutdown -s")
      

  2.   

    被抢先了
    Usage: shutdown [-i | -l | -s | -r | -a] [-f] [-m \\computername] [-t xx] [-c "c
    omment"] [-d up:xx:yy]        No args                 Display this message (same as -?)
            -i                      Display GUI interface, must be the first option
            -l                      Log off (cannot be used with -m option)
            -s                      Shutdown the computer
            -r                      Shutdown and restart the computer
            -a                      Abort a system shutdown
            -m \\computername       Remote computer to shutdown/restart/abort
            -t xx                   Set timeout for shutdown to xx seconds
            -c "comment"            Shutdown comment (maximum of 127 characters)
            -f                      Forces running applications to close without war
    ning
            -d [u][p]:xx:yy         The reason code for the shutdown
                                    u is the user code
                                    p is a planned shutdown code
                                    xx is the major reason code (positive integer less than 256)
                                    yy is the minor reason code (positive integer less than 65536)
      

  3.   

    你说关机的命令就不知道
    你用cmd /c 这样就不会出现窗口。其实是打开运行后自动关闭
      

  4.   

    用 cmd 的命令 shutdown -s