PsService - CMD


Overview

PsService is a command-line tool used for viewing and controlling services on local and remote Windows systems. It provides the capability to list, start, stop, query, and configure services, making it an invaluable tool in administrative scripting and system management.

Syntax

PsService [options] [command] [arguments]

Where:

  • [options]: Used to provide additional command modifiers.
  • [command]: Specifies the action to perform, such as query, start, stop, etc.
  • [arguments]: The target service(s) or options specific to the command.

Options/Flags

  • -d, --description : Shows the description of the service with the query output.
  • -e, -enum : Enumerates all the services on a system.
  • -h, --help : Displays help message and exits.
  • -p, --pswd : Specifies the password for the given user account (used with -u).
  • -u, --user : Specifies the user context in which the command should execute.

Example Flags Usage:

  • Adding -d with the query command will also display the service description.

Examples

  1. Querying the Status of a Service:

    PsService query "EventLog"
    

    This command checks the status of the ‘EventLog’ service.

  2. Stopping a Service:

    PsService stop "EventLog"
    

    Stops the ‘EventLog’ service.

  3. Starting a Service:

    PsService start "EventLog"
    

    Starts the ‘EventLog’ service once again if it was stopped.

  4. Listing All Services:

    PsService enum
    

    Lists all services installed on the system.

Common Issues

  • Permission Errors: If you encounter access denied errors, make sure to run PsService under an account with sufficient privileges.
  • Service Not Found: Ensure the service name is spelled correctly. Service names are case sensitive.

Integration

PsService can be combined with other scripts or tools for more extensive system management tasks. For example, creating a batch script that stops a list of services before deploying updates, then starts them again.

Example Batch Script:

@echo off
PsService stop "Service1"
PsService stop "Service2"
REM -- Perform system updates or changes here --
PsService start "Service1"
PsService start "Service2"
echo Services restarted
  • PsExec – Executes processes remotely.
  • PsList – Lists detailed information about processes.
  • PsKill – Kills undesirable processes.

Further Reading:
For more detailed information, refer to the official Sysinternals site: Sysinternals PsTools.

This manual provides a comprehensive look at the PsService command, aiding in managing services effectively across Windows environments.