Creating virtual directory within a virtual directory...

Posted on 2008-11-16
Last Modified: 2012-05-07
I'm having trouble finding a way to create a virtual directory within a folder that's inside a virtual directory.
ex:  in IIS I created a Virtual Directory called MySite.  That VD has a bunch of subdirectories within it and in order for my program to work, I need to also activate one of those subdirectories folders as a virtual directory.  I have not found a way to do it through a script, the only way I can do it now is to open IIS manager, right click on the folder and click the 'create' button.  Any help would be much appreiciated.
Question by:Mesite
    LVL 13

    Expert Comment

    These are basic steps to create VD in IIS.. By the way I guess you know these better..R u trying to create VD via script to skip this manual involvement ?

    In IIS Manager, expand the local computer and the Web site to which you want to add a virtual directory.

    Right-click the site or folder in which you want to create the virtual directory, click New, and then click Virtual Directory.

    In the Virtual Directory Creation Wizard, click Next.

    In the Alias box, type a name for the virtual directory and then click Next. Choose a short name that is easy to type, because users type this name to access the Web site.

    In the Path box, type or browse to the physical directory that contains the virtual directory, and then click Next.

    You can select an existing folder or create a new one to contain the content for the virtual directory.

    Select the check boxes for the access permissions that you want to assign to the users.

    By default, the Read and Run Scripts check boxes are selected. These permissions enable you to run ASP.NET pages for many common scenarios.

    Click Next and then click Finish.

    LVL 13

    Expert Comment

    CoGetObject Example  
    InstallShield DevStudio » InstallScript Language Reference

     * InstallShield Example Script
     * Demonstrates the CoGetObject function.
     * This example shows how to create a virtual
     * directory on IIS server.

    #include "ifx.h"

    #define VIRTUALDIR "My Virtual Dir"
    #define VIRTUALDIRPATH "c:\inetpub\wwwroot\MyDir"

    function OnBegin()
    OBJECT objIIS_Root, objVirtDir;


      set objIIS_Root = CoGetObject("IIS://localhost/W3SVC/1/Root", "");
      if (IsObject(objIIS_Root)) then
            set objVirtDir = objIIS_Root.Create("IISWebVirtualDir", VIRTUALDIR);
            if (IsObject(objVirtDir)) then
              objVirtDir.Path = VIRTUALDIRPATH;
              objVirtDir.AccessRead = TRUE;
              objVirtDir.AccessScript = TRUE;
          MessageBox("Unable to create Virual Directory.", INFORMATION);



    Author Comment

    Yes, I'm looking for an automated process.  I'm trying to create a VD witin a folder that's within an already established VD.  Here is a snippet of code and the something is the folder within the VD.  The VD that was created is MySite.:

        Set Site = getObject("IIS://localhost/W3svc/1/root/ & MySite & something")
    LVL 13

    Accepted Solution


    ' Create an instance of the virtual directory object  
    ' that represents the default Web site.
    Set IIsWebVDirRootObj = GetObject("IIS://localhost/W3SVC/1/Root")

    ' Use the Windows ADSI container object "Create" method to create  
    ' a new virtual directory.
    Set IIsWebVDirObj = IIsWebVDirRootObj.Create("IIsWebVirtualDir", "NewVDir")

    ' Use the Windows ADSI object "Put" method to  
    ' set some required properties.
    IIsWebVDirObj.Put "Path", "C:\NewContent"  
    IIsWebVDirObj.Put "AccessRead", True
    IIsWebVDirObj.Put "AccessScript", True

    ' Use the AppCreate2 method of the IIS ADSI provider to  
    ' create an application on the new virtual directory.
    IIsWebVDirObj.AppCreate2 1
    IIsWebVDirObj.Put "AppFriendlyName", "NewApp"

    ' Use the Windows ADSI object "SetInfo" method to  
    ' save the data to the metabase.


    I hope this takes you close to the solution...Make sure your ACL ( Permissions part in IIS is also given upto Administrator rights for your user access...Cheers Good luck..

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive + Dolby Voice = No More Audio Complaints!

    Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

    Logparser is the smartest tool I have ever used in parsing IIS log files and there are many interesting things I wanted to share with everyone one of the  real-world  scenario from my current project. Let's get started with  scenario - How do w…
    Prologue It is often required to host multiple websites on a single instance of IIS, mostly in development environments instead of on production servers. I am sure it is not much a preferred solution on production servers but this is at least a pos…
    Sending a Secure fax is easy with eFax Corporate ( First, Just open a new email message.  In the To field, type your recipient's fax number You can even send a secure international fax — just include t…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    758 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

    11 Experts available now in Live!

    Get 1:1 Help Now