傳回應用程式集區的執行時間狀態。
語法
objAppPool.GetState
var appPoolState = appPool.GetState();
參數
此方法不會採用任何參數。
傳回值
, uint32 識別應用程式集區狀態。 下表顯示傳回值。
| 傳回值 | 描述 |
|---|---|
| 0 | 表示應用程式集區正在啟動。 |
| 1 | 表示應用程式集區已啟動。 |
| 2 | 表示應用程式集區正在停止。 |
| 3 | 表示應用程式集區已停止。 |
| 4 | 表示應用程式集區狀態未知。 |
備註
這個方法不熟悉 IIS 7 WMI 提供者,而且 IIS 6.0 中沒有直接對應專案。
範例
下列範例會取得應用程式集區的狀態,並將它傳回給使用者。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Specify the application pool.
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='DefaultAppPool'")
' Get the application pool's state and return it to the user by
' calling a helper function.
WScript.Echo oAppPool.Name & " is " & GetStateDescription(oAppPool.GetState) & "."
' The helper function translates the return value into text.
Function GetStateDescription(StateCode)
Select Case StateCode
Case 0
GetStateDescription = "Starting"
Case 1
GetStateDescription = "Started"
Case 2
GetStateDescription = "Stopping"
Case 3
GetStateDescription = "Stopped"
Case 4
GetStateDescription = "Unknown"
Case Else
GetStateDescription = "Attempt to retrieve state failed."
End Select
End Function
規格需求
| 類型 | 描述 |
|---|---|
| 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 |