Using the WMI interface, you can programatically recycle the AppPool
Use MgmtClassGen from the SDK to generate your WMI class:
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\mgmtclassgen" IIsApplicationPool /n root\MicrosoftIISv2 /l VB /p IIsApplicationPool.vb
-or-
"C:\Program Files\Microsoft Visual Studio 8\SDK\v2.0\Bin\mgmtclassgen" IIsApplicationPool /n root\MicrosoftIISv2 /l CS /p IIsApplicationPool.cs
Then use this in your code:
Dim msScope As New ManagementScope("root\MicrosoftIISv2")
Dim wmiIISAppPool As IIsApplicationPool
Try
wmiIISAppPool = New IIsApplicationPool(msScope, String.Format("W3SVC/AppPools/{0}", _AppPoolID))
'Recycle it
wmiIISAppPool.Recycle()
Catch ex As Exception
LogEvent(" *** ERROR - AppPoolRecycle failed: AppPoolID: {0} {1}", _AppPoolID, ex.Message)
Finally
If Not wmiIISAppPool Is Nothing Then wmiIISAppPool.Dispose()
End Try