Click here to Skip to main content
12,450,101 members (47,350 online)
Click here to Skip to main content
Add your own
alternative version


10 bookmarked

VBScript to dump websitelayout and application running under AppPool in IIS WebServer

, 9 Dec 2005
Rate this:
Please Sign up or sign in to vote.
VBScript to Provide websitelayout for IIS WebServer


VBScript that will read the metabase information using WMI. This VBScript can be easily run at the client place and would tell us at one go what all web sites are running under Application Pools.

When we run this VBScript on client side it provide website layout in tree view format

+AppPoolId: DefaultAppPool
+WebSiteID: 1
+WebSite Name: Default web site
   -Application Name: W3SVC/1/ROOT
   -Application Name: W3SVC/1/ROOT/Timesheet
   -Application Name: W3SVC/1/ROOT/wiki
+WebSiteID: 2
+WebSite Name: Sukhvir Singh Nauhwar
   -Application Name: W3SVC/1/Forum

Now you can find out how many website running on particular Application Pools for IISWebServer

'This VBScript provide web site layout dump 
strComputer = "."
Set objWMIService = GetObject("winmgmts:{authenticationLevel=pktPrivacy}\\" &_
                             strComputer & "\root\microsoftiisv2")
Set colItemswb = objWMIService.ExecQuery( "Select * from IIsWebServerSetting" ) 

'Find Website Id
Dim WebSiteIds(10)
Dim WebSiteDisplayName(10)
n = 0
For Each objItemwb in colItemswb 
    WebSiteId = Mid(objItemwb.Name, 7) 
    WebSiteIds( n ) = WebSiteId
    WebSiteDisplayName(n) = objItemwb.ServerComment
    n = n + 1

n = n - 1 

Set colItems = objWMIService.ExecQuery("Select Name From IIsApplicationPool")
For Each objItem in colItems
    'Find Application Pool
    Dim AppPool
    Dim ln
    AppName = objItem.Name 
    AppPool = Mid(AppName , 16 ,ln) 
    Wscript.Echo "" 
    Wscript.Echo "+AppPoolId: " & AppPool
    For m = 0 to n 
        WebSiteId = WebSiteIds(m)
        objItem.EnumAppsInPool arrApplications
        displayWebSite = true
        'Find Application Name
        For i = 0 to Ubound(arrApplications)
            Dim application
            Dim length
            Dim arrApp
            arrApp = arrApplications(i)
            application = Mid(arrApp , 5 ,length)
            nextslashPos = InStr(7, application, "/")
            appwebsiteid = Mid(application, 7, nextslashPos - 7 )
            matchFound = StrComp( appwebsiteid, WebSiteId )
            If matchFound=0 then 
                if displayWebSite = true Then 
                    'Dispaly Website Id & Website Name
                    Wscript.Echo Space(4) &"+WebSiteID: " & WebSiteId 
                    Wscript.Echo Space(4) & "+WebSite Name: " &_
                    displayWebSite = false
                End If
                Wscript.Echo Space(8) & "-Application Name: " & application
            End if 
    Wscript.Echo "" 
    Wscript.Echo "" 
    Wscript.Echo "" 


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Web Developer
India India
Sukhvir Singh Nauhwar working as System Analyst.
I have done my M.C.A From Birla Institute of Technology, Mesra, Ranchi, India.

Having 8 years of experience in the field of Software Analysis, Design, Development, Porting, Testing, Documentation and Implementation of business applications.

Worked in diverse areas of business comprising Banking, Desktop Publishing, Telecom, Oil and Gas, Sales Distribution, Product Development, and Web Application.

My interested and primary skills are C, C++, Multithreading, Socket Programming, Perl, and Shell Programming on Unix/Linux/Solaris

You may also be interested in...


Comments and Discussions

GeneralDoes not work! Pin
Member #242070317-Jan-07 19:20
memberMember #242070317-Jan-07 19:20 
GeneralNo Article Pin
jonathan1530-Dec-05 4:06
memberjonathan1530-Dec-05 4:06 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.160826.1 | Last Updated 9 Dec 2005
Article Copyright 2005 by Nauhwar
Everything else Copyright © CodeProject, 1999-2016
Layout: fixed | fluid