Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is there a way to recycle all app pools on an IIS6 server at once without using iisreset or manually recycling each one?

share|improve this question
add comment

3 Answers

If you have the names of all the application pools, you could use iisapp.vbs (in systemroot\system32) in a script to restart them all.

iisapp /a NameOfAppPool /r
share|improve this answer
add comment
up vote 1 down vote accepted

I ended up using the following VBScript for IIS6:

Set oWMI = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}!root\MicrosoftIISv2")
Set aAppPools = oWMI.ExecQuery("Select * from IIsApplicationPool")

For Each oItem in aAppPools
    WScript.Echo("Recycling " & oItem.Name & "...")
    oAppPool.Recycle
Next

WScript.Echo("Recycled " & aAppPools.Count & " Application Pools.")

It has the advantage of not needing to know the names of the application pools beforehand, but you do have to have WMI enabled.

And the version for IIS7:

Set oWebAdmin = GetObject _
    ("winmgmts:{authenticationLevel=pktPrivacy}!root\WebAdministration")
Set aAppPools = oWebAdmin.InstancesOf("ApplicationPool")

For Each oAppPool in aAppPools
    WScript.Echo("Recycling " & oAppPool.Name & "...")
    oAppPool.Recycle
Next

WScript.Echo("Recycled " & aAppPools.Count & " Application Pools.")

Resources:
http://blogs.iis.net/chrisad/archive/2006/08/30/Recycling-Application-Pools-using-WMI-in-IIS-6.0.aspx
http://www.vbsedit.com/scripts/iis/iis6/apps/scr_476.asp
http://msdn.microsoft.com/en-us/library/ms525309(v=vs.90).aspx
http://learn.iis.net/page.aspx/162/managing-sites-with-iis39s-wmi-provider/

share|improve this answer
add comment

If you need to recycle them all, you might as well IISReset.

Alternatively (if this is, for example, an FTP preservation exercise), you could try restarting just the WWW Publishing service.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.