Remove a Virtual Directory (IIS 7)
Applies To: Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows Vista
If you no longer have to provide content from a virtual directory, you can remove the virtual directory.
The only virtual directory that you cannot remove from an application is its root virtual directory.
For information about the levels at which you can perform this procedure, and the modules, handlers, and permissions that are required to perform this procedure, see Virtual Directories Feature Requirements (IIS 7).
Exceptions to feature requirements
- Only server administrators can remove virtual directories.
To remove a virtual directory
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 use the UI
Open IIS Manager. For information about opening IIS Manager, see Open IIS Manager (IIS 7).
In the Connections pane, expand the Sites node in the tree, and then click to select the site for which you want to delete a virtual directory.
In the Actions pane, click View Virtual Directories.
On the Virtual Directories page, select the virtual directory that you want to remove.
In the Actions pane, click Remove and then Yes.
Removing a virtual directory in IIS does not delete the physical content from the Windows file system; it removes the relationship of the content as a virtual directory under an application.
To remove a virtual directory, use the following syntax:
appcmd delete vdir /vdir.name:string
The variable vdir.namestring is the virtual path of the virtual directory.
For example, to remove a virtual directory named photos from the root application of a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name:contoso/photos
To remove a virtual directory named photos from an application named marketing in a site named contoso, type the following at the command prompt, and then press ENTER:
appcmd delete vdir /vdir.name:contoso/marketing/photos
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.
Use the following WMI classes, methods, or properties to perform this procedure:
- VirtualDirectory.Delete_ method
To delete an instance of this object, use the object’s Delete_ system method that it inherits from WMI. For more information about Delete_, see SWbemObject.Delete_ on the MSDN site.
For more information about WMI and IIS, see Windows Management Instrumentation (WMI) in IIS 7. For more information about the classes, methods, or properties associated with this procedure, see the IIS WMI Provider Reference on the MSDN site.