Sysinternals/Pstools/PsService

From aldeid
Jump to navigation Jump to search
You are here:
PsService

Description

PsService is part of the PsTools toolkit developed by Sysinternals. PsService lists or controls services on a local or remote system.

Installation

PsService is part of the PsTools suite. To install it, please refer to this section.

Usage

Syntax

Usage: psservice [\\Computer [-u Username [-p Password]]] <cmd> <optns>
  • Omitting a command queries the active services on the specified computer.
  • Enter -? for help on a particular command.

Options (cmd)

query
Queries the status of a service
config
Queries the configuration
setconfig
Sets the configuration
start
Starts a service
stop
Stops a service
restart
Stops and then restarts a service
pause
Pauses a service
cont
Continues a paused service
depend
Enumerates the services that depend on the one specified
find
Searches for an instance of a service on the network
security
Reports the security permissions assigned to a service

Examples

Search the name of a service

Let's say we know that the remote machine is running Apache but we don't know the exact name of the service. Using query will enable to find it:

C:\pstools>psservice \\192.168.1.27 -u pilou -p oopsoops query apache

PsService v2.24 - Service information and configuration utility
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

SERVICE_NAME: Apache2.2
DISPLAY_NAME: Apache2.2
Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
        TYPE              : 10 WIN32_OWN_PROCESS
        STATE             : 4  RUNNING
                               (STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE   : 0  (0x0)
        SERVICE_EXIT_CODE : 0  (0x0)
        CHECKPOINT        : 0x0
        WAIT_HINT         : 0 ms

Stop a service

Now that we know the exact name of the service, let's stop it on the remote machine:

C:\pstools>psservice \\192.168.1.27 -u pilou -p oopsoops stop Apache2.2

PsService v2.24 - Service information and configuration utility
Copyright (C) 2001-2010 Mark Russinovich
Sysinternals - www.sysinternals.com

SERVICE_NAME: Apache2.2
DISPLAY_NAME: Apache2.2
Apache/2.2.21 (Win32) mod_ssl/2.2.21 OpenSSL/1.0.0e PHP/5.3.8 mod_perl/2.0.4 Perl/v5.10.1
        TYPE              : 10 WIN32_OWN_PROCESS
        STATE             : 3  STOP_PENDING
                               (NOT_STOPPABLE,NOT_PAUSABLE,IGNORES_SHUTDOWN)
        WIN32_EXIT_CODE   : 0  (0x0)
        SERVICE_EXIT_CODE : 0  (0x0)
        CHECKPOINT        : 0x4
        WAIT_HINT         : 30000 ms

Comments