独自の .vbs スクリプトを記述して、AppPool の .State を検索し、停止時に開始することができます。何かのようなもの:
//編集:
Option Explicit
If WScript.Arguments.Count <> 1 Then
Wscript.Echo "No AppPoolName provided. Iterate through all AppPools"
iterate_and_start_all_apps()
Else
Dim AppPoolName
AppPoolName = Wscript.Arguments(0)
'
' Choose what to do here and uncomment that Sub
'
' start_given_app(AppPoolName)
' start_one_app_if_stopped(AppPoolName)
' start_recycle_stop_app(AppPoolName)
End If
' This Sub is runs if no argument is passed to the script
Sub iterate_and_start_all_apps()
Dim objAppPools, objAppPool
Set objAppPools = GetObject("IIS://Localhost/W3SVC/AppPools")
For Each objAppPool in objAppPools
Set objAppPool = GetObject("IIS://Localhost/W3SVC/AppPools/" & objAppPool.Name )
If objAppPool.AppPoolState <> 2 Then
Wscript.Echo objAppPool.Name & " is not running."
WScript.Echo objAppPool.Name & ", AppPoolState: " & objAppPool.AppPoolState & _
", Win32Error: " & objAppPool.Win32Error & " ("& hex(objAppPool.Win32Error)&")"
Wscript.Echo State2Desc(objAppPool.AppPoolState)
objAppPool.Start
If Err.Number = 0 Then
Wscript.Echo objAppPool.Name & " started."
End If
End If
Next
Set objAppPool = Nothing
Set objAppPools = Nothing
End Sub
'
' start an application pool if the .State is stopped
'
Sub start_one_app_if_stopped(applicationpool)
Dim iisObjectPath : iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & applicationpool)
Dim iisObject : Set iisObject = GetObject(iisObjectPath)
If iisObject.AppPoolState <> 2 Then
iisObject.Start
If (Err.Number <> 0) Then
WScript.Echo "Error starting: " & ObjectPath
WScript.Quit (Err.Number)
Else
WScript.Echo applicationpool & " started."
End If
End If
Set iisObject = nothing
Set iisObjectPath = nothing
End Sub
'
' if an application pool is stopped, start + recycle + stop it
'
Sub start_recycle_stop_app(applicationpool)
Dim iisObjectPath : iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & applicationpool)
Dim iisObject : Set iisObject = GetObject(iisObjectPath)
If iisObject.AppPoolState <> 2 Then
iisObject.Start
If (Err.Number <> 0) Then
WScript.Echo "Error starting: " & ObjectPath
WScript.Quit (Err.Number)
Else
WScript.Echo applicationpool & " started."
End If
iisObject.recycle
' we need to sleep for some time because recyle takes some time
wscript.sleep(3000)
iisObject.Stop
End If
Set iisObject = nothing
Set iisObjectPath = nothing
End Sub
'
' just issue a start command to start an application pool
'
Sub start_given_app(applicationpool)
Dim iisObjectPath : iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & applicationpool)
Dim iisObject : Set iisObject = GetObject(iisObjectPath)
IIsObject.Start
If (Err.Number <> 0) Then
WScript.Echo "Error starting: " & ObjectPath
WScript.Quit (Err.Number)
Else
WScript.Echo applicationpool & " started."
End If
Set iisObject = nothing
Set iisObjectPath = nothing
End Sub
'
' support function
'
Function State2Desc(nState)
Select Case nState
Case 1
State2Desc = "Starting"
Case 2
State2Desc = "Started"
Case 3
State2Desc = "Stopping"
Case 4
State2Desc = "Stopped"
Case Else
State2Desc = "Unknown state"
End Select
End Function
(すべてのアプリケーション プールを開始するスクリプトであるhttp://www.saotn.org/iis-60-start-gestopte-application-pools/から一部抜粋)。
「startapp.vbs」として保存し、次のように実行します。
cscript.exe /nologo startapp.vbs name_of_appPool
引数なしで開始すると、スクリプトはメタベース内のすべてのアプリケーション プールを反復処理し、それらが実行されていない場合はそれらを開始します。
「start_one_app_if_stopped」サブが必要になると思うので、その行 (13 行目) のコメントを外し、コマンド ライン引数を指定して .vbs スクリプトを実行します。
cscript.exe /nologo startapp.vbs name_of_appPool
HTH