Compartir a través de


Site.GetState Method1

Devuelve el estado en tiempo de ejecución de un sitio web.

Sintaxis

objSite.GetState  
var siteState = objSite.GetState();  

Parámetros

Este método no toma parámetros.

Valor devuelto

Un uint32 identifica el estado del sitio web. Los valores devueltos se muestran en la tabla siguiente.

Valor devuelto Descripción
0 Indica que el sitio web se está iniciando.
1 Indica que se ha iniciado el sitio web.
2 Indica que el sitio web se está deteniendo.
3 Indica que el sitio web se ha detenido.
4 Indica que el estado del sitio web es desconocido.

Ejemplo

En el ejemplo siguiente se obtiene el estado de un sitio web y se devuelve al usuario.

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Specify the Web site.  
Set oSite = oWebAdmin.Get("Site.Name='IISWebSite'")  
  
' Get the Web site's state and return it to the user by  
' calling a helper function.  
WScript.Echo oSite.Name & " is " & GetStateDescription(oSite.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  

Requisitos

Tipo Descripción
Remoto - IIS 7.0 en Windows Vista
- IIS 7.5 en Windows 7
- IIS 8.0 en Windows 8
- IIS 10.0 en Windows 10
Server - IIS 7.0 en Windows Server 2008
- IIS 7.5 en Windows Server 2008 R2
- IIS 8.0 en Windows Server 2012
- IIS 8.5 en Windows Server 2012 R2
- IIS 10.0 en Windows Server 2016
Producto - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
Archivo MOF WebAdministration.mof

Consulte también

Clase de sitio