WorkerProcessContainsAppDomain Class2

Provides a relationship between a worker process and its application domains.

Syntax

class WorkerProcessContainsAppDomain : ObjectContainerAssociation  

Methods

This class contains no methods.

Properties

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

Name Description
Container (Inherited from ObjectContainerAssociation.) A read-only WorkerProcess object that represents an IIS worker process. A key property.
Element (Inherited from ObjectContainerAssociation.) A read-only AppDomain object that represents an IIS application domain. A key property.

Subclasses

This class contains no subclasses.

Remarks

This association class is useful for retrieving all the loaded application domains for each worker process on a Web server.

Example

The following example displays the loaded application domains on a Web server. The first part uses a WMI query. The second part uses the WorkerProcessContainsAppDomain association class.

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get application domains on the server by using a WMI query.  
Set AppDomains = oWebAdmin.ExecQuery ("Select * from AppDomain")  
  
WScript.Echo "AppDomain Count: " & AppDomains.Count  
WScript.Echo  
For Each AppDomain In AppDomains  
    WScript.Echo "AppDomain site name: " + AppDomain.SiteName  
    WScript.Echo "AppDomain process ID: " & AppDomain.ProcessID  
    WScript.Echo "AppDomain ID: " + AppDomain.Id  
    WScript.Echo "AppDomain application path: " & _  
        AppDomain.ApplicationPath  
    WScript.Echo       
Next  
  
WScript.Echo  
  
' Get the application domains for each worker process by using  
' the WorkerProcessContainsAppDomain association.  
Set oWorkerProcesses = oWebAdmin.InstancesOf("WorkerProcess")  
  
For Each oWorkerProcess In oWorkerProcesses  
    WScript.Echo "Worker Process Process ID: " & oWorkerProcess.ProcessID  
    Set oAppDomains = _  
    oWorkerProcess.Associators_("WorkerProcessContainsAppDomain")  
  
    WScript.Echo "AppDomainCount: " & oAppDomains.Count  
    WScript.Echo  
    WScript.Echo "List of AppDomains"  
    WScript.Echo "------------------"  
    For Each oAppDomain In oAppDomains  
        WScript.Echo "Application domain process ID: " & _  
            oAppDomain.ProcessId  
        WScript.Echo "Application domain application path:" & _  
            oAppDomain.ApplicationPath  
        WScript.Echo " Application domain physical path: " & _  
            oAppDomain.PhysicalPath  
        WScript.Echo  
    Next   
Next  

Note the following syntax from the preceding code example.

Set oAppDomains = _

oWorkerProcess.Associators_("WorkerProcessContainsAppDomain")

To simplify your code, you can instead use the following syntax, which enables you to use the association without having to remember its exact name.

Set oAppDomains = oWorkerProcess.Associators_(, "AppDomain")

Inheritance Hierarchy

ObjectContainerAssociation

WorkerProcessContainsAppDomain

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

AppDomain Class
ObjectContainerAssociation Class
WorkerProcess Class