Sc queryex

 

Applies To: Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7, Windows Server 2003 with SP2, Windows Server 2003 R2, Windows Server 2008 R2, Windows Server 2012, Windows Server 2003 with SP1, Windows 8

Obtains and displays extended information about the specified service, driver, type of service, or type of driver.

For examples of how to use this command, see Examples.

Syntax

sc [<ServerName>] queryex [type= {driver | service | all}] [type= {own | share | interact | kernel | filesys | rec | adapt}] [state= {active | inactive | all}] [bufsize= <BufferSize>] [ri= <ResumeIndex>][group= {"" | <GroupName>}]

Parameters

Parameter

Description

<ServerName>

Specifies the name of the remote server on which the service is located. The name must use the Universal Naming Convention (UNC) format (for example, \\myserver). To run SC.exe locally, omit this parameter.

<ServiceName>

Specifies the service name returned by the getkeyname operation. This queryex parameter is not used in conjunction with any other queryex parameters except ServerName.

type= {driver | service | all}

Specifies what to enumerate. The default value for the first type is service.

driver: Specifies that only drivers are enumerated.

service: Specifies that only services are enumerated.

all: Specifies that both drivers and services are enumerated.

type= {own | share | interact | kernel | filesys | rec | adapt}

Specifies the type of services or type of drivers to enumerate. The default value for the second type is own.

own: The service runs in its own process. It does not share an executable file with other services.

share: The service runs as a shared process. It shares an executable file with other services.

interact: The service can interact with the desktop, receiving input from users. Interactive services must be run under the LocalSystem account.

kernel: Driver.

filesys: File system driver.

state= {active | inactive | all}

Specifies the started state of the service for which to enumerate. The default state is active.

active: Specifies all active services.

inactive: Specifies all paused or stopped services.

all: Specifies all services.

bufsize= <BufferSize>

Specifies the size (in bytes) of the enumeration buffer. The default buffer size is 1024 bytes.

ri= <ResumeIndex>

Specifies the index number at which to begin or resume the enumeration. The default value is 0.

group= <GroupName>

Specifies the service group to enumerate. By default, all groups are enumerated (group= "").

/?

Displays help at the command prompt.

Remarks

  • For each command-line option, the equal sign is part of the option name.

  • A space is required between an option and its value (for example, type= own. If the space is omitted, the operation will fail.

  • The queryex command displays the following information about a service: SERVICE_NAME (service's registry subkey name), TYPE, STATE (as well as states that are not available), WIN32_EXIT_B, SERVICE_EXIT_B, CHECKPOINT, WAIT_HINT, PID, and FLAGS.

  • You can use the type= parameter twice in some cases. The first appearance of the type= parameter specifies whether to query services, drivers, or both (all). The second appearance of the type= parameter specifies a type from the create operation to further narrow a query's scope.

  • When the display resulting from a queryex command exceeds the size of the enumeration buffer, a message similar to the following is displayed:

    Enum: more data, need 2130 bytes start resume at index 75

    To display the remaining queryex information, rerun queryex, setting bufsize= to be the number of bytes and setting ri= to the specified index. For example, the remaining output would be displayed by typing the following at the command prompt:

    sc queryex bufsize= 2130 ri= 75
    

Examples

To display extended information about the MESSENGER service, type:

sc queryex messenger

To display extended information about all service groups, type:

sc queryex group= ""

Additional references

Command-Line Syntax Key