sodcalculator

10 Tech How-To

Restart or Shutdown PC via Command Prompt

Guide 10-42674 · Updated · Step by step

This guide shows you how to shut down or restart a Windows computer using the Command Prompt. It is useful when the Start menu is unresponsive, you need to schedule a restart, or you want to force-close hung applications. You only need a Windows PC and permission to open Command Prompt.

What You’ll Need

  • A Windows PC (Windows 10 or Windows 11 recommended).
  • An administrator account (for most shutdown/restart commands, a standard account works, but some options like remote shutdown require admin rights).
  • Command Prompt open. You can open it by pressing Windows Key + R, typing cmd, and pressing Enter. For admin rights, press Ctrl + Shift + Enter instead.

Step-by-Step

  1. Open Command Prompt. Press Windows Key + R, type cmd, and hit Enter. If you need administrator privileges (for example, to shut down a remote computer), right-click the result and choose Run as administrator.
  2. Type the basic shutdown command. To shut down immediately, type:
    shutdown /s /t 0
    Press Enter. The computer will shut down right away.
  3. Restart immediately. Type:
    shutdown /r /t 0
    Press Enter. The PC will restart instantly.
  4. Add a delay. Replace 0 with the number of seconds you want to wait. For example, to restart in 5 minutes (300 seconds), type:
    shutdown /r /t 300
  5. Add a custom message. Use the /c flag to show a message before the action. For example:
    shutdown /s /t 60 /c "Saving work - system will shut down in 1 minute."
  6. Force close apps. If programs are not responding, add /f to force them to close without warning. Be careful: unsaved work will be lost. Example:
    shutdown /r /f /t 30
  7. Cancel a scheduled shutdown. If you change your mind, type:
    shutdown /a
    Press Enter. This only works if the countdown has not reached zero yet.
  8. Shut down a remote computer. Type:
    shutdown /s /m \\COMPUTERNAME /t 0
    Replace COMPUTERNAME with the actual network name. You need admin rights and the remote PC must be on the same network.
  9. Log off instead. Use shutdown /l to log off the current user. This is faster than a full shutdown.
  10. Check help. Type shutdown /? to see all available options and their syntax.

Common Mistakes

  • Forgetting the /t flag. If you type shutdown /s without /t, the default is 30 seconds, not immediate. Always include /t 0 for instant action.
  • Using /a too late. The abort command only works during the countdown. Once the shutdown begins, you cannot cancel it.
  • Confusing /s and /r. /s shuts down, /r restarts. Mixing them up can cause unexpected downtime.
  • Not running as admin for remote shutdown. Remote shutdown requires elevated privileges. If you get an “Access denied” error, run Command Prompt as administrator.
  • Using /f without saving. The /f flag closes all apps without saving. Make sure you have saved your work before using it.

Tips

  • Combine flags for convenience: shutdown /r /f /t 60 restarts after 60 seconds and forces apps to close.
  • Use a short delay (like 10 seconds) to give yourself time to cancel if you accidentally trigger a shutdown.
  • Create a desktop shortcut with the command to restart or shut down with one click. Right-click the desktop, choose New > Shortcut, and enter shutdown /s /t 0 as the location.
  • For a full list of options, type shutdown /? in the Command Prompt window.
  • If you are on a laptop, the shutdown command works the same as pressing the power button, but it will not put the PC to sleep.

Troubleshooting

Command not recognized. This usually means you are not in Command Prompt but in PowerShell or another shell. Type cmd and press Enter to switch, or open Command Prompt from the Start menu.

Access denied error. You need administrator privileges. Close Command Prompt, right-click it, and select Run as administrator.

The shutdown is aborted automatically. Some programs (like a pending Windows update) can cancel a shutdown. Check for update notifications and try again.

Remote shutdown fails. Ensure the remote computer is on, connected to the network, and you have the correct computer name. Also, the remote PC must allow remote shutdown in its firewall settings.

The countdown message does not appear. The /c message only shows if you include the /t flag with a positive delay. If you use /t 0, the message is skipped.

Frequently Asked Questions

Q: Can I shut down my computer after a specific time, like in 2 hours?
A: Yes, use shutdown /s /t 7200 (2 hours = 7200 seconds).

Q: How do I restart my computer without closing apps?
A: Windows does not support a restart that keeps apps open. You can use shutdown /r but apps will close. To preserve your session, use Hibernate instead.

Q: Is there a way to shut down without a countdown?
A: Yes, use shutdown /s /t 0. The computer shuts down immediately.

Q: Can I use this command to shut down another computer on my network?
A: Yes, with shutdown /s /m \\ComputerName, but you need admin rights and the remote computer must be configured to allow it.

Q: What does the /f flag do?
A: It forces running applications to close without warning. It is useful when an app is frozen, but you may lose unsaved data.

Q: How do I cancel a scheduled shutdown?
A: Type shutdown /a in Command Prompt. This only works if the countdown is still active.

Related

General steps for current mainstream versions; menus can differ by device and version. See the disclaimer or report an error.

More in this bed

The whole Tech How-To bed →