Site.GetState Method1
返回网站的运行时状态。
语法
objSite.GetState
var siteState = objSite.GetState();
参数
此方法不采用参数。
返回值
一个用于标识网站状态的 uint32
。 下表显示了返回值。
返回值 | 说明 |
---|---|
0 | 指示网站正在启动。 |
1 | 指示网站已启动。 |
2 | 指示网站正在停止。 |
3 | 指示网站已停止。 |
4 | 指示网站状态为未知。 |
示例
以下示例获取网站的状态,并将其返回给用户。
' 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
要求
类型 | 描述 |
---|---|
客户端 | - IIS 7.0(在 Windows Vista 上) - IIS 7.5(在 Windows 7 上) - IIS 8.0(在 Windows 8 上) - IIS 10.0(在 Windows 10 上) |
服务器 | - IIS 7.0(在 Windows Server 2008 上) - IIS 7.5(在 Windows Server 2008 R2 上) - IIS 8.0(在 Windows Server 2012 上) - IIS 8.5(在 Windows Server 2012 R2 上) - IIS 10.0(在 Windows Server 2016 上) |
产品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
MOF 文件 | WebAdministration.mof |