Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8775499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T18:48:49+00:00 2026-06-13T18:48:49+00:00

I’m looking for a DOS command to list all sites and virtual directories in

  • 0

I’m looking for a DOS command to list all sites and virtual directories in IIS 6 under Windows 2003. I know there are ways to do this using Powershell / WMI, VBS, C#, etc. But all I want is a quick and dirty, no-fuss way to do it from DOS, without the need to create any new files on the Webserver.

EDIT: While researching for this question I managed to come up with a one-liner that does it, but please do suggest an alternative if you have a more elegant solution that fits the criteria above.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T18:48:50+00:00Added an answer on June 13, 2026 at 6:48 pm

    Here’s what I came up with:

    @FOR /F "delims=[]" %A IN ('@cscript //nologo %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs ENUM /P /w3svc') DO @FOR /F delims^=^"^ tokens^=2 %B IN ('@cscript //nologo %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs GET %A/ServerComment') DO @FOR /F delims^=^"^ tokens^=2 %C IN ('@cscript %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs //nologo GET %A/Root/Path') DO @ECHO %A %B "%C"
    

    The command outputs a list of virtual directory ID’s, along with the “friendly name” and path for each, e.g.:

    /w3svc/1 Default Web Site "c:\inetpub\wwwroot"
    /w3svc/1236224994 FunWidgets "C:\Inetpub\wwwroot\FunWidgets"
    /w3svc/1359392326 JimSmith.com "C:\Inetpub\wwwroot\JimSmith"
    /w3svc/1835917338 BouncyToys "C:\Inetpub\wwwroot\bouncytoys"
    /w3svc/198968327 AvalonWest "C:\Inetpub\wwwroot\AvWest"
    

    If you want to pipe the output to a text file, first make sure it doesn’t exist, then append >> filename.txt to the command above. (e.g.: DEL sites.txt & ... >> sites.txt)

    Here’s a breakdown of how the admittedly convoluted command works:

    1. @ is prefixed to every statement to avoid echoing the statement itself, which would pollute the output.

    2. @FOR /F "delims=[]" %A IN ('@cscript //nologo %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs ENUM /P /w3svc') DO

      Invokes AdsUtil.vbs, which is installed with IIS6 (and reads the metabase on our behalf).

      • The ENUM /P /w3svc parameter tells it to spit out a list of all sites and virtual directory ID’s starting at the root node.
      • The nologo switch suppresses the usual CScript copyright preamble, to render only the output we’re interested in. A double-backslash is used to escape the slash character, since we’re inside a string.
      • The output of the portion in single quotes resembles the following:

        [/w3svc/1]
        [/w3svc/1236224994]
        [/w3svc/1359392326]
        [/w3svc/1835917338]
        [/w3svc/198968327]
        [/w3svc/AppPools]
        [/w3svc/Filters]
        [/w3svc/Info]
        

      This is passed into FOR /F, which loops through each line. delims=[] tells FOR to treat square brackets as delimiters. Everything after the DO will be executed once for each line, with the %A variable set to whatever is between the square brackets. (If this was a batch file you’d use %%A instead).

    3. @FOR /F delims^=^"^ tokens^=2 %B IN ('@cscript //nologo %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs //nologo GET %A/ServerComment') DO

      This second FOR block runs AdsUtil with the GET parameter to retrieve the ServerComment property for the given site / virtual directory. This is the human-friendly name as seen in IIS. Unfortunately the output is a bit trickier to parse. e.g. For /w3svc/1 you get back:

      ServerComment                   : (STRING) "Default Web Site"
      

      The careting trick parses out the text between the quotes.

      Note that nodes we aren’t interested (AppPools, Filters and Info) don’t have the ServerComment property, and give a result devoid of quotes, e.g.:

      The path requested could not be found.
      ErrNumber: -2147024893 (0x80070003)
      Error Trying To GET the Object (GetObject Failed): w3svc/Filters
      

      Thus the remaining portion of the command line is not invoked for them.

    4. @FOR /F delims^=^"^ tokens^=2 %C IN ('@cscript %SystemDrive%\Inetpub\AdminScripts\adsutil.vbs //nologo GET %A/Root/Path') DO @ECHO %A %B "%C"

      This final FOR retrieves the physical path, then outputs all three pieces of parsed information to the console.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I know there's a lot of other questions out there that deal with this
Let's say I'm outputting a post title and in our database, it's Hello Y’all
I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a text area in my form which accepts all possible characters from
Does anyone know how can I replace this 2 symbol below from the string
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.