Script to Stop Application Pools on Windows

VB script to Stop Application Pools on Windows IIS 6

As  SysAdmin, We sometimes need to auto-stop some application pools in order to run a specific task like IIS logs cleanup.

This script will detect all application pools that are running and stop them.

=====================
myComputer = “.”
Set objWMIService = GetObject (“winmgmts:\\” & myComputer & “\root\microsoftiisv2”)
Set colItems = objWMIService.ExecQuery (“Select name from IISApplicationPoolSetting where AppPoolState = 2”)
For Each objItems In colItems
poolname=objItems.name
WScript.Echo poolname
AppPoolStop(poolname)
Next
Function AppPoolStop(PoolName)
set PoolcolItems = objWMIService.ExecQuery (“Select name from IISApplicationPool where name='” & poolname & “‘”)
For Each objItem In PoolcolItems
objitem.Stop
Next
End Function
===============
Enter that script in a text file, save it with extension “.vbs”. Copy it at C:\Windows\System32\
Run it manually or via a batch scheduler.
Thanks to Euk-marie. See the equivalent script by Euk-Marie to start the App Pool at https://www.eukhost.com/forums/f15/start-application-pool-simple-script-8937/
Etienne Noumen

Sports Lover, Linux guru, Engineer, Entrepreneur & Family Man.

Recent Posts

SQL Interview Questions and Answers

SQL Interview Questions and Answers In the world of data-driven decision-making, SQL (Structured Query Language)…

1 week ago

Things To Consider When Switching Internet Providers

Before you make the decision to switch your home’s interest service provider, take the time…

3 weeks ago

A Daily Chronicle of AI Innovations in April 2024

AI Innovations in April 2024. Welcome to the April 2024 edition of the Daily Chronicle,…

4 weeks ago

Everything To Know About Bioreactors and How They Work

A bioreactor is the silent hero behind the scenes contributing to many of everyday life’s…

4 weeks ago

Business Leadership: How To Overcome Communication Failures

Don’t let a few obstacles get in the way of success. Learn how to overcome…

1 month ago

Differences Between Power Strips and Surge Protectors

A power strip and a surge protector might seem like the same device, but there…

1 month ago