IIS 6.0: stop, start or recycle application pools

Date posted: 2013-02-20
Last updated: 2026-06-01

Somewhere in my archives, I found this VBScript for stopping, starting and recycling an IIS 6.0 application pool. It doesn’t use adsutil.vbs. It might come in handy, because it’s always very time consuming to start the Computer Management console, click through Services and Applications > Internet Information Services (IIS) Manager > Application Pools to find the Application Pool you want to start, stop or recycle.

Somewhere in my archives, I found this VBScript for stopping, starting and recycling an IIS 6.0 application pool. It doesn’t use adsutil.vbs. It might come in handy, because it’s always very time consuming to start the Computer Management console, click through Services and Applications > Internet Information Services (IIS) Manager > Application Pools to find the Application Pool you want to start, stop or recycle.

Be careful, this one is off the old shelf, but may come in handy to start, stop or recycle your old IIS 6.0 application pools.

VBScript and ADSI: stop, start or recycle a given application pool on IIS 6.0

You now have the power of the command line! (next to AdsUtil.vbs ofcourse 😉 ).

This VBScript uses a website identifier to find out the application pool the website runs in. It can be easily changed to using a website name (Description) instead. Change “Localhost” to a servername-variable, and you can use it remote! See comments.

VBScript/ADSI script for stopping, starting or recycling application pools

Option explicit
' IIS 6.0: stop, start or recycle an application pool
' cscript.exe StopStartRecycleAppPool.vbs <IIS_website id> <stop|start|recycle>

' If WScript.Arguments.Count <> 1 Then
'   Wscript.Echo "No ServerName provided."
'   Wscript.Quit
' Else
'   Dim ServerName
'   ServerName = Wscript.Arguments(0)
'   ServerName = Lcase(ServerName)
' End If

Dim WebsiteID, Command
If WScript.Arguments.Count < 2 Then
  WScript.Echo "Enter a website id and command (""stop"", ""start"" or ""recycle"")."
  WScript.Quit
End If

WebsiteID = WScript.Arguments(0) 
Command = WScript.Arguments(1)
If Not IsNumeric(WebsiteID) Or WebsiteID < 1 Then
  WScript.Echo "Incorrect IIS website identifier"
  Wscript.Quit
End If

Dim iisObject, iisObjectPath, AppPool, RESULT
iisObjectPath = ("IIS://Localhost/W3SVC/" & WebsiteID & "/ROOT")
Set iisObject = GetObject(iisObjectPath)
  AppPool = iisObject.AppPoolId
Set iisObject = nothing

Select Case (Command)
  Case "stop"
    stop_app()
  Case "start"
    start_app()
  Case "recycle"
    recycle_app()
  Case Else
    WScript.Echo "Command not recognised: " & Args(1)
    WScript.Quit
End Select

Function stop_app()
  iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & AppPool)
  Set iisObject = GetObject(iisObjectPath)
    IIsObject.Stop
    If (Err.Number <> 0) Then
      ReportError ()
      WScript.Echo "Error trying to stop: " & ObjectPath
      WScript.Quit (Err.Number)
    Else
      WScript.Echo AppPool & " stopped."
    End If
  Set iisObject = nothing
End Function

Sub start_app()
  iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & AppPool)
  Set iisObject = GetObject(iisObjectPath)
    IIsObject.Start
    If (Err.Number <> 0) Then
      ReportError ()
      WScript.Echo "Error starting: " & ObjectPath
      WScript.Quit (Err.Number)
    Else
      WScript.Echo AppPool & " started."
    End If
  Set iisObject = nothing
End Sub

Sub recycle_app()
  iisObjectPath = ("IIS://Localhost/W3SVC/AppPools/" & AppPool)
  Set iisObject = GetObject(iisObjectPath)
    IIsObject.Recycle
    If (Err.Number <> 0) Then
      ReportError ()
      WScript.Echo "Error recycling: " & ObjectPath
      WScript.Quit (Err.Number)
    End If
      WScript.Echo AppPool & " recycled."
  Set iisObject = nothing
End Sub

StopStartRecycleAppPool.vbs usage

Let’s assume 132456 is IIS’ identifier number for a website:

Stop application pool

cscript.exe /nologo StopStartRecycleAppPool.vbs 132456 stop

Start application pool

cscript.exe /nologo StopStartRecycleAppPool.vbs 132456 start

Recycle application pool

cscript.exe /nologo StopStartRecycleAppPool.vbs 132456 recycle

Adsutil.vbs: stop, start and recycle application pool with adsutil.vbs

Of course you can use adsustil.vbs too to stop, start or recycle an application pool. Simply use cmd.exe to go to C:\Inetpub\AdminScripts and use cscript.exe. I’ll use the DefaultAppPool (W3SVC/1) as example.

Stop (disable) application pool with adsutil.vbs

cscript.exe /nologo adsutil.vbs stop_server W3SVC/AppPools/DefaultAppPool

Start application pool with adsutil.vbs

cscript.exe /nologo adsutil.vbs start_server W3SVC/AppPools/DefaultAppPool

Recycle application pool with adsutil.vbs

There is no real recycle option available in adsutil.vbs. Just simply stopping and starting the AppPool has the same effect.

cscript.exe /nologo adsutil.vbs stop_server W3SVC/AppPools/DefaultAppPool
cscript.exe /nologo adsutil.vbs start_server W3SVC/AppPools/DefaultAppPool

Start, stop and recycle application pools on IIS 7, 7.5, 8.0, 8.5 with AppCmd.exe

Are you looking for how to conditionally start an application pool with AppCmd? Or some ready to use AppCmd snippets & examples?

Summary

  • The article provides a VBScript for stopping, starting, and recycling IIS 6.0 application pools without using adsutil.vbs.
  • It emphasizes the time-saving aspect of using command line scripts compared to navigating the IIS Manager interface.
  • Instructions include using an identifier number for application pools and changing parameters for remote use.
  • Adsutil.vbs can also control application pools, allowing similar functions but lacks a dedicated recycle option.
  • Finally, the article mentions AppCmd.exe for managing application pools on IIS 7 and later versions.

Read why we can use your help and support ❤️

Rate this post!

Leave a Comment