提供應用程式集區與其背景工作進程之間的關聯性。
Syntax
class ApplicationPoolContainsProcess : ObjectContainerAssociation
方法
這個類別不包含方法。
屬性
下表列出 類別所 ApplicationPoolContainsProcess 公開的屬性。
| 名稱 | 描述 |
|---|---|
Container |
(繼承自 ObjectContainerAssociation.) 代表 IIS 應用程式集區的唯讀 ApplicationPool 物件。 索引鍵屬性。 |
Element |
(繼承自 ObjectContainerAssociation .) 代表 Windows Process Activation Service (WAS) 背景工作進程的唯讀 WorkerProcess 物件。 索引鍵屬性。 |
子類別
這個類別不包含子類別。
備註
物件 WorkerProcess 是暫時性的;當應用程式集區被回收或到達閒置逾時時,它可能會停止存在。如果您撰寫的腳本與物件互動 WorkerProcess 的時間長度很長,請做好此可能性的準備。
範例
下列範例會傳回伺服器上每個應用程式集區中每個背景工作進程的識別碼。
' 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
請注意上述程式碼範例的下列這一行。
Set colAppPools = oWebAdmin.ExecQuery("SELECT * FROM ApplicationPool")
除了使用 ExecQuery 方法,您也可以使用 WMI InstancesOf 方法,如下所示:
Set colAppPools = oWebAdmin.InstancesOf("ApplicationPool")
後者的方法可讓您達成相同的結果,而不需指定查詢語法。
使用任一種方法,腳本會產生類似下列的輸出:
Application Pool Name: DefaultAppPool
Application Pool Name: Classic .NET AppPool
Application Pool Name: NewAppPool1
Application Pool Name: NewAppPool2
Application Pool Name: NewAppPool3
繼承階層架構
ApplicationPoolContainsProcess
規格需求
| 類型 | 描述 |
|---|---|
| Client | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10上的 IIS 10.0 |
| 伺服器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016上的 IIS 10.0 |
| 產品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
| MOF 檔案 | WebAdministration.mof |
另請參閱
ApplicationPool 類別
ObjectContainerAssociation 類別
ProcessModelSettings 類別
WorkerProcess 類別