Windows关机命令教程

所有现代Windows操作系统都提供了shutdown命令,用于从命令行轻松关闭Windows系统。shutdown命令与用于不同关机行为的不同选项一起使用。

null

关机命令语法

shutdown 命令具有以下简单语法,其中只能为shutdown命令提供选项。为了运行shutdown命令,用户必须 Shut down the system 通常提供给普通用户的用户权限。

shutdown OPTION
  • 选项将更改关机命令的行为。

关机选项和参数

shutdown命令提供了许多选项,以便重新启动、完全关闭或注销当前用户会话。

期权 说明
/我 显示远程关机框
/我 立即注销当前用户会话
/s码 关闭计算机
/右 重启电脑
/a 中止关机
/小时 休眠计算机
/电子 注意停机原因
/f级 在没有警告用户的情况下强制关闭
/米 指定远程计算机
/t型 设置超时时间或延迟
/d级 列出重新启动或关闭的原因
/c级 注释关闭原因(仅限511个字符)
/? 显示帮助信息

显示帮助信息

有关shutdown命令的详细帮助信息可以在命令行中列出 /? 参数。

C:>shutdown /?
Usage: shutdown [/i | /l | /s | /sg | /r | /g | /a | /p | /h | /e | /o] [/hybrid] [/soft] [/fw] [/f]
    [/m computer][/t xxx][/d [p|u:]xx:yy [/c "comment"]]

    No args    Display help. This is the same as typing /?.
    /?         Display help. This is the same as not typing any options.
    /i         Display the graphical user interface (GUI).
               This must be the first option.
    /l         Log off. This cannot be used with /m or /d options.
    /s         Shutdown the computer.
    /sg        Shutdown the computer. On the next boot, if Automatic Restart Sign-On
               is enabled, automatically sign in and lock last interactive user.
               After sign in, restart any registered applications.
    /r         Full shutdown and restart the computer.
    /g         Full shutdown and restart the computer. After the system is rebooted,
               if Automatic Restart Sign-On is enabled, automatically sign in and
               lock last interactive user.
               After sign in, restart any registered applications.
    /a         Abort a system shutdown.
               This can only be used during the time-out period.
               Combine with /fw to clear any pending boots to firmware.
    /p         Turn off the local computer with no time-out or warning.
               Can be used with /d and /f options.
    /h         Hibernate the local computer.
               Can be used with the /f option.
    /hybrid    Performs a shutdown of the computer and prepares it for fast startup.
               Must be used with /s option.
    /fw        Combine with a shutdown option to cause the next boot to go to the
               firmware user interface.
    /e         Document the reason for an unexpected shutdown of a computer.
    /o         Go to the advanced boot options menu and restart the computer.
               Must be used with /r option.
    /m computer Specify the target computer.
    /t xxx     Set the time-out period before shutdown to xxx seconds.
               The valid range is 0-315360000 (10 years), with a default of 30.
               If the timeout period is greater than 0, the /f parameter is
               implied.
    /c "comment" Comment on the reason for the restart or shutdown.
               Maximum of 512 characters allowed.
    /f         Force running applications to close without forewarning users.
               The /f parameter is implied when a value greater than 0 is
               specified for the /t parameter.
    /d [p|u:]xx:yy  Provide the reason for the restart or shutdown.
               p indicates that the restart or shutdown is planned.
               u indicates that the reason is user defined.
               If neither p nor u is specified the restart or shutdown is
               unplanned.
               xx is the major reason number (positive integer less than 256).
               yy is the minor reason number (positive integer less than 65536).

Reasons on this computer:
(E = Expected U = Unexpected P = planned, C = customer defined)
Type    Major   Minor   Title

 U      0       0       Other (Unplanned)
E       0       0       Other (Unplanned)
E P     0       0       Other (Planned)
 U      0       5       Other Failure: System Unresponsive
E       1       1       Hardware: Maintenance (Unplanned)
E P     1       1       Hardware: Maintenance (Planned)
E       1       2       Hardware: Installation (Unplanned)
E P     1       2       Hardware: Installation (Planned)
E       2       2       Operating System: Recovery (Unplanned)
E P     2       2       Operating System: Recovery (Planned)
  P     2       3       Operating System: Upgrade (Planned)
E       2       4       Operating System: Reconfiguration (Unplanned)
E P     2       4       Operating System: Reconfiguration (Planned)
  P     2       16      Operating System: Service pack (Planned)
        2       17      Operating System: Hot fix (Unplanned)
  P     2       17      Operating System: Hot fix (Planned)
        2       18      Operating System: Security fix (Unplanned)
  P     2       18      Operating System: Security fix (Planned)
E       4       1       Application: Maintenance (Unplanned)
E P     4       1       Application: Maintenance (Planned)
E P     4       2       Application: Installation (Planned)
E       4       5       Application: Unresponsive
E       4       6       Application: Unstable
 U      5       15      System Failure: Stop error
 U      5       19      Security issue (Unplanned)
E       5       19      Security issue (Unplanned)
E P     5       19      Security issue (Planned)
E       5       20      Loss of network connectivity (Unplanned)
 U      6       11      Power Failure: Cord Unplugged
 U      6       12      Power Failure: Environment
  P     7       0       Legacy API shutdown

我们可以看到帮助信息还提供了关机原因及其代码。

相关文章: PowerShell写主机命令教程

关闭计算机

如果你执行 shutdown 命令,它将显示帮助信息。为了关闭计算机,你必须提供 /s 选项。这也可以称为关闭计算机或系统。执行命令后,需要60秒才能开始关闭操作。

C:> shutdown /s

中止或取消关机操作

由于停机操作在60秒后开始,您可以使用 /a 参数。

C:> shutdown /a

规定时间后停机

默认情况下,关机操作在命令执行60秒后开始。我们还可以定义自定义计时器,其中关闭在指定的分钟后开始。这个 /t 命令可用于指定延迟分钟数。在下面的示例中,计算机在10分钟后关闭。

C:> shutdown /s /t 10

您还可以使用 /t 选项。在下面的示例中,计算机将在10分钟后重新启动。

C:> shutdown /r /t 10

关闭远程计算机/系统

shutdown命令也可用于关闭远程计算机或系统。要关闭远程系统,应该将其集成到windows域中,或者您应该为远程系统用户提供凭据。这个 /m 选项可用于指定远程计算机或系统。可以毫无问题地提供远程系统的域名或IP地址。

C:> shutdown /s /m 192.168.10.10

或者域名可以指定如下。

C:> shutdown /s /m dc.windowstect.com

设置关机注释

特别是对于Windows服务器,关闭不是一个常规操作,通常是出于特定的原因执行的。可以通过使用/c选项对关闭操作进行注释,并以双引号提供注释或消息。

C:> shutdown /s /c "I have installed some updates"

重新启动或重新启动计算机

默认情况下,使用 /s 选项将完全关闭系统,不再启动。您可以使用 /r 选项。

C:> shutdown /r

注销当前用户会话

shutdown命令可用于注销当前用户会话。您可以通过提供 /l 选项。当前会话将在没有任何警告的情况下立即关闭。

C:> shutdown /l

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享