Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Returns the run-time state of an application pool.
Syntax
objAppPool.GetState
var appPoolState = appPool.GetState();
Parameters
This method takes no parameters.
Return Value
A uint32 that identifies the application pool state. The return values are shown in the following table.
| Return value | Description | 
|---|---|
| 0 | Indicates that the application pool is starting. | 
| 1 | Indicates that the application pool has started. | 
| 2 | Indicates that the application pool is stopping. | 
| 3 | Indicates that the application pool has stopped. | 
| 4 | Indicates that the application pool state is unknown. | 
Remarks
This method is new to the IIS 7 WMI provider and has no direct counterpart in IIS 6.0.
Example
The following example gets the state of an application pool and returns it to the user.
' 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
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 |