Freigeben über


ApplicationPoolContainsProcess Class [IIS 7 and higher]

Provides a relationship between an application pool and its worker processes.

Syntax

class ApplicationPoolContainsProcess : ObjectContainerAssociation

Methods

This class contains no methods.

Properties

The following table lists the properties exposed by the ApplicationPoolContainsProcess class.

Name

Description

Container

(Inherited from ObjectContainerAssociation.) A read-only ApplicationPool object that represents an IIS application pool. A key property.

Element

(Inherited from ObjectContainerAssociation.) A read-only WorkerProcess object that represents a Windows Process Activation Service (WAS) worker process. A key property.

Subclasses

This class contains no subclasses.

Remarks

A WorkerProcess object is transient; it may cease to exist when its application pool is recycled or when it reaches its idle time-out. Be prepared for this possibility if you write a script that interacts with a WorkerProcess object over any significant length of time.

Example

The following example returns the ID for every worker process in each application pool on a server.

' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")

' Return all application pools that are present on the server.
Set colAppPools = oWebAdmin.ExecQuery("SELECT * FROM ApplicationPool")

' Return the name of each application pool.
For Each oAppPool In colAppPools
        WScript.Echo "Application Pool Name: " & oAppPool.Name

        ' Get all worker processes in the application pool.
        Set oProcesses = oAppPool.Associators_("ApplicationPoolContainsProcess")

        ' Return the ID of each worker process in the application pool.
        For Each oProcess In oProcesses
                WScript.Echo "Worker Process ID: " & oProcess.ID
        Next
Next

Note the following line from the preceding code example.

Set colAppPools = oWebAdmin.ExecQuery("SELECT * FROM ApplicationPool")

Instead of using the ExecQuery method, you can alternatively use the WMI InstancesOf method, as follows:

Set colAppPools = oWebAdmin.InstancesOf("ApplicationPool")

The latter approach enables you to achieve the same result without specifying a query syntax.

With either approach, the script produces an output similar to the following:

Application Pool Name: DefaultAppPool

Application Pool Name: Classic .NET AppPool

Application Pool Name: NewAppPool1

Application Pool Name: NewAppPool2

Application Pool Name: NewAppPool3

Inheritance Hierarchy

ObjectContainerAssociation

   ApplicationPoolContainsProcess

Requirements

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

See Also

Reference

ApplicationPool Class [IIS 7 and higher]

ObjectContainerAssociation Class [IIS 7 and higher]

ProcessModelSettings Class [IIS 7 and higher]

WorkerProcess Class [IIS 7 and higher]