ApplicationPool.GetState Method2

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 - 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

ApplicationPool Class