Enabling WebDAV on IIS 6

I had a great question from someone the other day about enabling WebDAV on IIS 6, so I wrote a simple Windows Script Host (WSH) utility that does the trick. Because I'm a firm believer that writing code for one person will ultimately benefit someone else, I'm making that script the subject of today's blog post. ;-)

Note: The following script makes use of several IIS 6 metabase properties, and you can see the following topics for more information:

To use this script, use the following steps:

  • Copy the WSH code listed below and paste it into a text editor, such as Windows Notepad:
    Option Explicit
    
    ' --------------------------------------------------
    ' Part 1: Enable the WebDAV Web Service Extension.
    ' --------------------------------------------------
    
    ' Retrieve an object for the W3SVC root.
    Dim objIIsWebService
    Set objIIsWebService = GetObject("IIS://localhost/W3SVC")
    ' Enable the WebDAV Web Service Extension.
    objIIsWebService.EnableWebServiceExtension "WEBDAV"
    ' Save the changes to the metabase.
    objIIsWebService.SetInfo
    
    ' --------------------------------------------------
    ' Part 2: Enable the WebDAV-related attributes for the Default Web Site.
    ' --------------------------------------------------
    
    ' Retrieve an object for the web site root.
    Dim objIIsWebSite
    Set objIIsWebSite = GetObject("IIS://localhost/W3SVC/1/ROOT")
    ' Enable the WebDAV-related access flags.
    objIIsWebSite.AccessRead = True
    objIIsWebSite.AccessSource = True
    objIIsWebSite.AccessWrite = True
    ' Enable the directory browsing - required for file listings.
    objIIsWebSite.EnableDirBrowsing = True
    ' Save the changes to the metabase.
    objIIsWebSite.SetInfo
    
  • Update the metabase path for your web site to IIS://localhost/W3SVC/nnn/ROOT, where nnn is the identifier for the web site where you want to enable WebDAV. Note: The web site identifier can be found in the IIS Manager using the following steps:
    • Open the IIS manager.
    • Expand the local computer node. 
    • Highlight the Web Sites node.
    • Notice the site ID in the "Identifier" column.
  • Save the file as EnableWebDav.vbs to your desktop and close your text editor.

Note: This script is not designed the new WebDAV module for IIS 7. To manage the WebDAV module in IIS 7, see the following topics:

I hope this helps!

No Comments