How to get an ADSI reference to an IIS subdirectory?

Posted on 2009-02-16
Last Modified: 2012-05-06
My default website in IIS6 isn't anything special: I have a few subdirectories below the root (/css, /images), some files across the site, and that's it.  I don't have any virtual directories configured.

I want to programmatically set the content expiration on the [/css] and [/images].  I have some code written below, but the script fails on the GetObject() call.  What am I doing wrong?
Dim oIIsImagesDir

set oIIsImagesDir = GetObject("IIS://localhost/W3SVC/1/ROOT/css")

if IsObject(oIIsImagesDir) then


	'Call WScript.Echo("oIIsImagesDir.HttpExpires = " & oIIsImagesDir.HttpExpires)

	'oIIsImagesDir.HttpExpires= "D, 0x15180"

end if

Open in new window

Question by:deathtospam
    1 Comment
    LVL 22

    Accepted Solution

    If you run the script via cscript - what's the error number that is shown?  Google should get you the solution from there...  Off-hand, it's likely to be a permissions issue.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Join & Write a Comment

    I guess it is not common knowledge to most Wintel engineers/administrators: If you have an SNMP-based monitoring system in your environment (and it's common to have SNMP or Syslog) it's reasonably easy to enable monitoring of the Windows Event logs,…
    Running classic asp applications under Windows Server 2008 R2 (x64) and IIS 7 is not as easy as one may think. It took me a while to figure it out while getting error 8002801d a few times. After you install the OS you will need to install the fol…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now