Creating virtual directory within a virtual directory...

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.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Praveen DMInfra Team LeadCommented:
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.

Praveen DMInfra Team LeadCommented:
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);


MesiteAuthor Commented:
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")
Praveen DMInfra Team LeadCommented:

' 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..

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft IIS Web Server

From novice to tech pro — start learning today.