You can perform this procedure by using the user interface (UI), by running Appcmd.exe commands in a command-line window, by editing configuration files directly, or by writing WMI scripts.
To add a virtual directory to the root application in a site, use the following syntax:
appcmd add vdir /app.name:
string
/ /path:
string
/physicalPath:
string
The variable app.namestring is the site name and the / following the name specifies that the virtual directory should be added to the root application of the site. The variable pathstring is the virtual path of the virtual directory, such as /photos, and physicalPathstring is the physical path of the virtual directory's content in the file system.
For example, to add a virtual directory named photos with a physical location of c:\images to the root application in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd add vdir /app.name:
contoso
/ /path:/
photos
/physicalPath:c:\
images
To add a virtual directory to an application other than a site's root application, type the name of the application after / in app.namestring. For example, to add the same virtual directory used in the previous example to an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd add vdir /app.name:
contoso
/
marketing
/path:/
photos
/physicalPath:c:\
images
For more information about Appcmd.exe, see Appcmd.exe (IIS 7).
The procedure in this topic affects the following configuration elements:
<virtualDirectory> under <application> element
For more information about IIS 7 configuration, see IIS 7.0: IIS Settings Schema on MSDN.