Condividi tramite


Metodo Site.GetState1

Restituisce lo stato di runtime di un sito Web.

Sintassi

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

Parametri

Questo metodo non accetta parametri.

Valore restituito

Oggetto uint32 che identifica lo stato del sito Web. I valori restituiti vengono visualizzati nella tabella seguente.

Valore restituito Descrizione
0 Indica che il sito Web viene avviato.
1 Indica che il sito Web è stato avviato.
2 Indica che il sito Web viene arrestato.
3 Indica che il sito Web è stato arrestato.
4 Indica che lo stato del sito Web è sconosciuto.

Esempio

L'esempio seguente ottiene lo stato di un sito Web e lo restituisce all'utente.

' 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  

Requisiti

Tipo Descrizione
Client - IIS 7.0 in Windows Vista
- IIS 7.5 in Windows 7
- IIS 8.0 in Windows 8
- IIS 10.0 in Windows 10
Server - IIS 7.0 in Windows Server 2008
- IIS 7.5 in Windows Server 2008 R2
- IIS 8.0 in Windows Server 2012
- IIS 8.5 in Windows Server 2012 R2
- IIS 10.0 in Windows Server 2016
Prodotto - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
File MOF WebAdministration.mof

Vedere anche

Classe del sito