PsShutdown - CMD


Overview

PsShutdown is a command-line utility for Windows that enables users to shutdown, reboot, or suspend a local or remote computer. It is particularly useful in administrative environments, as it facilitates the management of computer states across a network. Advanced features include timed shutdown, logging off the current user, and the ability to execute the shutdown without requiring user interaction.

Syntax

The basic syntax for PsShutdown is:

PsShutdown \\computer [-u user [-p password]] [options]
  • \\computer: Specifies the target computer. Default is the local computer.
  • -u user: Specifies the username for login to the remote computer.
  • -p password: Specifies the password for the user account.

Options/Flags

  • -a: Aborts a shutdown (only possible while a countdown is in progress).
  • -d: Suspends the computer.
  • -e: Shuts down and powers down the computer.
  • -f: Forcibly closes applications at shutdown.
  • -h: Hibernates the computer.
  • -k: Powers off the computer (does not imply shutdown).
  • -l: Log off the current user.
  • -m: Sends the shutdown command to the computer’s motherboard.
  • -n [delay]: Delays executing the shutdown command by the specified number of seconds (default is 20).
  • -r: Reboot after shutdown.
  • -s: Shutdown without power off.
  • -t: Specifies the timeout period before shutdown (in seconds).
  • -v: Display verbose output.

Examples

  1. Remote Shutdown:
    To shutdown a remote computer:

    PsShutdown \\REMOTE_PC -u User -p Password -s
    
  2. Forcibly Reboot:
    To restart the local computer and force close all applications:

    PsShutdown -r -f
    
  3. Hibernate Local Computer:
    To hibernate the local computer:

    PsShutdown -h
    
  4. Delayed Shutdown:
    To shutdown the computer after a delay of 60 seconds:

    PsShutdown -s -t 60
    

Common Issues

  • Network Permissions: When targeting remote systems, ensure the user account has the necessary administrative privileges to execute a shutdown.
  • Application Closure Resistance: Some applications may not close if the -f flag is not used, potentially causing the command to fail.
  • Abort Timing: The -a option can only cancel a shutdown if it was initiated with a delay (-t flag).

Integration

PsShutdown can be combined with other CMD commands for complex tasks. For example, creating a batch script to shutdown a group of computers listed in a file:

for /F "tokens=*" %%i in (computers.txt) do PsShutdown \\%%i -s -f
  • shutdown.exe: Similar to PsShutdown but a built-in Windows command with different options.
  • psshutdown.exe: Part of the Sysinternals Suite, offering similar functionality with different advanced features.

For further learning and documentation, refer to the Sysinternals Suite on Microsoft Docs.