web123456

cmd shutdown command: shut down, restart, sleep

Turn off after a period of time:

shutdown -s -t secondsThe effect is to shut down after counting down to that number of seconds. For example, shutdown -s -t 3600 is shut down after 3600 seconds, that is, shut down after one hour.

Shutdown command now:

shutdown -pTurn off the local computer, the effect is to shut down immediately without counting down
Can also be usedshutdown -s -t 0Set the power off after 0 seconds, which means shutting down immediately.

Restart after a while

shutdown -r -t seconds, the effect is to count down the number of seconds and restart, for exampleshutdown -r -t 0Restart after countdown 0 seconds, that isRestart nowMeaning, if not added-tThe parameters will count down the default number of seconds and then shut down, usually one minute.

Hibernation command

shutdown -h,This command makes the computer sleep, which means it is completely powered off, but it will save the current computer status. The opened programs are still there next time you start it. A virtual machine-like suspend function.

Sleep command

The difference between sleep and sleep is that sleep does not completely lose power, and other power-consuming parts in the computer are turned off, leaving only memory for power supply. Next time when the computer is awakened, it will return to its previous state. This is similar to dormant, and the advantage of sleep is that it starts quickly. You can sleep if you leave the computer for a short time, and if the time interval is relatively long, you can sleep. Hibernation is power-consuming just like shutting down, and sleep still consumes power because it also supplies power to memory.

Use command line tools to achieve sleep

Go directly to the Microsoft official website to download the software.Please go to this page and click Download.
Then enter the decompressed folder in the command line and enter: -d -t 0

Use nircmd to achieve sleep

Enter the commandnircmd standbySleep (that is, standby state)

Enable screen protection

cmdEnter below LockWorkStation, you can activate the screen protection function, so that you need to enter your password when you want to use the computer again. You can prevent others from touching your computer when you leave for a short time.

Show shutdown command syntax

When I don’t understand the command, I usually search online, but I found that all the information on the Internet is introduced. In fact, the most important thing to do is to view it directly in cmd and the official introduction document.
entershutdown -helpshowshutdownHow to use the instruction

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 parameters Show help.  This is the same as typing /?.
     /? Show help.  This is the same as not typing any options.
     /i Displays the graphical user interface (GUI).
                This has to be the first option.
     /l Log out.  This cannot be used with the /m or /d options.
     /s Turn off the computer.
     /sg Turn off the computer.  On the next startup,
                Restart any registered application.
     /r Completely shut down and restart the computer.
     /g Turn off completely and restart the computer.  After restarting the system,
                Restart any registered application.
     /a Aborts the system shutdown.
                This can only be used during timeouts.
                Used in conjunction with /fw to clear any unfinished boot to firmware.
     /p Turn off the local computer without timeout or warning.
                Can be used with the /d and /f options.
     /h Hibernate the local computer.
                Can be used with the /f option.
     /hybrid Performs computer shutdown and prepares for quick start.
                Must be used with the /s option.
     /fw is used in conjunction with the shutdown option to turn to the next startup
                Firmware user interface.
     /e Records the reason why the computer is shut down unexpectedly.
     /o Go to the Advanced Startup Options menu and restart your computer.
                Must be used with the /r option.
     /m \\computer Specifies the target computer.
     /t xxx Set the timeout before closing to xxx seconds.
                The effective range is0-315360000 (10Year), the default value is30.
                If the timeout is greater than0, then implies
                /f parameter.
     /c"comment"Comments about the reasons for restarting or shutting down.
                Maximum allowed512characters.
     /f Forces the running application to close without warning the user in advance.
                If the /t parameter is specified to be greater than0value,
                This is implied as the /f parameter.
     /d [p|u:]xx:yy Provides reasons for restarting or shutting down.
                p indicates that restart or shutdown is planned.
                u indicates that the reason is user-defined.
                If p and u are not specified, restart or close
                It's unplanned.
                xx is the main reason number (less than256positive integer).
                yy is the secondary reason number (less than65536positive integer).

 Reasons on this computer:
 (E= Expected U = Unexpected P = Planned,C= Custom)
 Category Major Secondary Title

  U0       0Others (unplanned)E       0       0Others (unplanned)E P     0       0Others (planned)
  U0       5Other faults: The system has no responseE       1       1Hardware: Maintenance (unplanned)E P     1       1Hardware: Maintenance (planned)E       1       2Hardware: Installation (unplanned)E P     1       2Hardware: Installation (planned)E       2       2Operating System: Recovery (Unplanned)E P     2       2Operating system: Recovery (planned)
   P2       3Operating system: Upgrade (planned)E       2       4Operating System: Reconfiguration (unplanned)E P     2       4Operating system: Reconfiguration (planned)
   P2       16Operating system: Service Pack (planned)2       17Operating system: Hot patching (unplanned)
   P2       17Operating system: Hot patching (planned)2       18Operating system: Security patching (unplanned)
   P2       18Operating system: Security patching (planned)E       4       1Application: Maintenance (unplanned)E P     4       1Application: Maintenance (planned)E P     4       2Application: Install (planned)E       4       5Application: No responseE       4       6Application: Unstable
  U5       15System failure: Stop error
  U5       19Security issues (unplanned)E       5       19Security issues (unplanned)E P     5       19Security issues (planned)E       5       20Lost network connection (unplanned)
  U6       11Power failure: The wire was unplugged
  U6       12Power failure: Environment
   P7       0Old version of API shutdown

It can be seen from the help documentation
shutdown -hIt means: Hibernate the local computer, and the computer will hibernate immediately after executing this command. The -h parameter can be used with the -f parameter, but cannot be used with the -t parameter. That's to sayshutdown -h -t 3600This usage is wrong.

shutdown -pTurn off the local computer, the computer will be shut down immediately after executing the command, and will not wait for the default time.

shutdown -sIndicates shutting down the local computer, if not used-tIf the parameters are counted down, the default event will be counted down. If the -t parameter is used, the countdown will be counted down and the time set will be shut down. For example,shutdown -s -t 3600that is3600Turn off in seconds.

shutdown -rIndicates that the computer is completely shut down and restarted. Just reboot, you can add it-tSet how much time to count down to restart, for exampleshutdown -r -t 3600It's the countdown3600Restart in seconds, andshutdown -r -t 0It is to restart after countdown 0 seconds, that isRestart now

shutdown -aIndicates canceling shutdown or canceling restart. existshutdown -sorshutdown -rExecute before the countdown endsshutdown -aCancel shutdown or restart operations.