我想获取应用程序池的状态。我从here获取了vbscript。
strArgAppPool = Wscript.Arguments.Unnamed.Item(0)
Const noError = False
' Establish the connection to the WMI provider
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Search the AppPool passed as argument in the list of application pools
Set oAppPool = oWebAdmin.Get("ApplicationPool.Name='" & strArgAppPool & "'")
' Create nice messages for pool states
Select Case oAppPool.GetState
Case 0
StateDescription = "STARTING"
outputStatus = "WARNING! "
outputCode = 1
Case 1
StateDescription = "STARTED"
outputStatus = "OK! "
outputCode = 0
Case 2
StateDescription = "STOPPING"
outputStatus = "WARNING! "
outputCode = 1
Case 3
StateDescription = "STOPPED"
outputStatus = "CRITICAL!! "
outputCode = 2
Case 4
StateDescription = "UNKNOWN"
outputStatus = "UNKNOWN? "
outputCode = 3
Case Else
StateDescription = "UNDEFINED VALUE"
outputStatus = "UNKNOWN? "
outputCode = 3
End Select
' Output
Wscript.Echo outputStatus & oAppPool.Name & ": " & StateDescription
' Error handling
If noError = true Then
' Error message
Wscript.echo "UNKNOWN: Error during the WMI query for app pool " & strArgAppPool & " !"
' Exit & return code
WScript.Quit(3)
Else
' Clean exit
WScript.Quit(outputCode)
End If
通过批处理文件我试图将其作为
运行status1.vbs "DefaultAppPool"
但我最终得到了这个
有些服务没有启动吗?我试过直接运行vb脚本。我试过没有引号和所有类似的东西传递参数。我不编写脚本,但这次必须这样做。
错误对话框指示第5行Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
。我已经在过去的5个小时内尽我所能。我有一个现成的脚本,我无法运行它。羞耻,并不愿意这一切发表这个问题。但最终输了。谢谢你的帮助。
我还有一个IIS 6的工作脚本。我通过远程服务器上的PsExec
调用此脚本。但是这在IIS 7中不起作用。如果有人要我发布,请告诉我。此外,我现在正在使用IIS 7和Server 2008 R2,并将使用远程服务器上的PsExec
运行此脚本。
答案 0 :(得分:5)
您没有安装角色服务 IIS管理脚本和工具。启动服务器管理器,转到角色→Web服务器(IIS),然后安装缺少的服务。