Hi,
If Windows 2003 SP1 has been installed, we now add a new /r switch to
iisapp.vbs which can be used to recycle app pools:
cscript iisapp.vbs /a DefaultAppPool /r
You can refer to the source of iisapp.vbs for the detail.
Below is sample script based on WMI. Simply name it to IISRECYCLE.VBS to
use. Please note the AppPoolName argument need to be case-sensitive.
' <----------------- code begin ----------------->
'By Default Recycle All App Pools
bRecycleAll = 1
If Wscript.arguments.count = 0 Then
Wscript.Echo "Syntax: cscript iisrecycle.vbs server
[AppPoolName]"
WScript.Echo "Example: cscript iisrecycle.vbs localhost
DefaultAppPool"
WScript.Quit (0)
Else
strServer = WScript.arguments(0)
If WScript.arguments.count > 1 Then
strAppPoolName = WScript.arguments(1)
bRecycleAll = 0
End If
End If
set Locator = CreateObject("WbemScripting.SWbemLocator")
set Service = locator.connectserver(strServer,"root/MicrosoftIISv2")
service.Security_.AuthenticationLevel = 6
set APCollection = Service.InstancesOf("IISApplicationPool")
If bRecycleAll = 1 Then
For each APInstance in APCollection
APInstance.Recycle
Next
Else
For each APInstance in APCollection
If UCase(ApInstance.Name) = UCase("W3SVC/AppPools/"
& strAppPoolName) Then
APInstance.Recycle
End If
Next
End If
' <----------------- code end ----------------->
Have a good day.
Sincerely,
WenJun Zhang
Microsoft Online Community Support
==================================================
Get notification to my posts through email? Please refer to:
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at:
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.