我想获取应用程序池的状态。我从这里获取了 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
在远程服务器上运行此脚本。