Iisvdir.vbs: IIS virtual directory script
To view the command syntax, click a command:
iisvdir /create
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- The WebSite (or WebSite/VirtualPath), Name, and PhysicalPath parameters must always appear in the specified order on the command line. Otherwise, Iisvdir.vbs does not interpret the information correctly.
- When you use Iisvdir.vbs to create a new virtual directory, you specify only the basic properties needed to create the site and identify its contents. Iisvdir.vbs uses the same default properties that IIS uses when establishing new virtual directories, and it adheres to the same rules for inheriting properties. To configure the more advanced properties of the site, use IIS Manager.
- Virtual directory names (Name) are not required to be unique. However, when a Web site includes a virtual directory and a physical directory with the same name, then the physical directory content cannot be viewed on the Internet.
Examples
To create a virtual directory at the root of the Web site
iisvdir /create Finance Insurance c:\projects\insurance\html
In response, Iisvdir.vbs displays the following message, which indicates that the command was successful, and it also displays the basic properties of the new virtual directory:
Connecting to server ...Done. Virtual Path = Finance/Insurance ROOT = c:\projects\insurance\html Metabase Path = W3SVC/1509060625/ROOT/Insurance
The WebSite, Name, and PhysicalPath parameters must appear in the specified order in the command. The following command is the same as the previous command except that the parameters are out of order:
iisvdir /create c:\projects\insurance\html Finance Insurance
This command fails and, having misinterpreted the parameters, Iisvdir.vbs reports that it cannot find a Web site called "c:."
To create a virtual directory in a Web site path
The command creates the new virtual directory as a subdirectory of the Finance/Insurance directory. The command uses the metabase path of the Finance Web site, W3SVC/1509060625, to identify the Web site. It indicates the virtual path, Finance/Insurance, by appending it to the Web site name.
Finally, the command associates the Updates directory with content stored in C:\Newstuff\Web on the remote computer.
iisvdir /createW3SVC/1509060625/InsuranceUpdatesC:\Newstuff\Web/s svr01/u Admin01/p p@SSw#rD2
In response, Iisvdir.vbs displays the following message, which indicates that the command was successful, and it also displays the basic properties of the new virtual directory:
Connecting to server ... Done. Virtual Path = Finance/Insurance/Updates ROOT = C:\Newstuff\Web Metabase Path = W3SVC/1509060625/ROOT/Insurance/Updates
In this example, the Finance Web site and its Insurance subdirectory existed on the Svr01 IIS server before the command was issued. If the Web site or the subdirectory did not exist, the command would have failed.
Also, the Insurance subdirectory is a virtual directory. You can use Iisvdir.vbs to create virtual paths within actual or virtual directories.
To create a virtual directory to hide a physical directory
Although this method does not secure or protect the physical directory, it does provide a measure of privacy.
The following command creates a virtual directory named Personnel at the root of the Finance Web Site. The virtual directory is associated with a physical directory, D:\IIStest\Personnel, that contains public information about the Finance department team.
iisvdir /create Finance Personnel D:\IIStest\Personnel
In response, Iisvdir.vbs displays the following message, which indicates that the command was successful, and it also displays the basic properties of the new virtual directory:
Connecting to server ... Done. Virtual Path = Finance/Personnel ROOT = D:\IIStest\Personnel Metabase Path = W3SVC/1509060625/ROOT/Personnel
As a result of this command, the site has a physical directory and a virtual directory named Personnel. Users who access the Finance Web site see the contents of the Personnel virtual directory. They do not see the contents of the Personnel physical directory.
iisvdir /delete
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- Do not use Iisvdir.vbs to delete a Web site. If you do, the Web site is still listed, but it is partially removed and does not operate properly. To delete a Web site, or to correct the improper removal of an Web site by Iisvdir.vbs, use Iisweb.vbs: IIS Web site management script .
Examples
To delete a virtual directory
iisvdir /deleteFinance/Insurance
In response, Iisvdir.vbs displays the following message, indicating that the command was successful. Note that Iisvdir.vbs does not ask for confirmation before deleting the directory or its subdirectories.
Web directory Finance/ROOT/Insurance has been DELETED.
iisvdir /query
Syntax
Parameters
Remarks
- To perform this procedure, you must be a member of the Administrators group on the local computer, or you must have been delegated the appropriate authority. If the computer is joined to a domain, members of the Domain Admins group might be able to perform this procedure. As a security best practice, consider using Run as to perform this procedure.
- The query operation displays only virtual directories. Physical directories in the Web site or path do not appear.
- The query operation displays only virtual directories at the root of the Web site or in the specified subdirectory. It does not search recursively.
Examples
To display the virtual directories of a Web site
iisvdir /query Finance
In response, Iisvdir.vbs displays the two virtual directories at the root of Finance. Note that these directories appear at the Finance root even though their physical locations are unrelated.
This display does not include virtual directories that are subdirectories of the site. The procedure for finding subdirectories is demonstrated in the example below, "To display virtual subdirectories."
Alias Physical Root ====================================================== /Personnel D:\Corpdir\FinanceWeb\People /Insurance C:\Marketing\Insurance\HTMFiles
To display virtual subdirectories
iisvdir /query Finance\Insurance
This command reveals the Current subdirectory of the Insurance virtual directory.
Alias Physical Root ====================================================== /Current C:\Insurance\Monthly\200204
Remarks
- Iisvdir.vbs performs the same operations that are available from IIS Manager. You can use either tool to view and manage virtual directories.
- The computer issuing the command must be running Windows XP or a Windows Server 2003 operating system. The user must be a member of the Administrators group on any computer that the command affects.
- The computer that the command affects must be a server running Windows Server 2003 with Internet Information Services (IIS) 6.0.
- Iisvdir.vbs displays a "Connecting to server" message while it connects to the IIS service on the specified computer. This message appears whenever you use Iisback.vbs, whether on a local or a remote computer.
- Use quotation marks to enclose path elements that include spaces. Enclose only the element with spaces, not the entire path. For example, type "Default Web Site"/IISAdmin, not "Default Web Site/IISAdmin".
Formatting legend
Format | Meaning |
Italic | Information that the user must supply |
Bold | Elements that the user must type exactly as shown |
Ellipsis (...) | Parameter that can be repeated several times in a command line |
Between brackets ([]) | Optional items |
Between braces ({}); choices separated by pipe (|). Example: {even|odd} | Set of choices from which the user must choose only one |
Courier font | Code or program output |