Iisvdir.vbs: IIS virtual directory script
Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
Iisvdir.vbs: IIS virtual directory script
Creates and deletes virtual directories of Web sites on servers running Windows Server 2003 with Internet Information Services (IIS) 6.0.
To view the command syntax, click a command:
iisvdir /create
iisvdir /delete
iisvdir /query
iisvdir /create
Creates virtual directories on Web sites on servers running Windows Server 2003 with Internet Information Services (IIS) 6.0.
Syntax
iisvdir[.vbs] /create WebSite[/VirtualPath] Name PhysicalPath [/sComputer [/u [Domain**\]User [/p** Password]]]
Parameters
- WebSite
Required. Specifies the descriptive name or metabase path of the Web site.
- VirtualPath
Specifies a path to the virtual directory within the Web site. The virtual path does not include the name of the virtual directory.
This parameter places the virtual directory in a subdirectory of the Web site. By default, the virtual directory is added to the root of the Web site. All directories in the virtual path must already exist on the Web site.
- Name
Required. Specifies a name for the virtual directory. You can select any name.
- PhysicalPath
Required. Specifies a physical directory for the virtual directory.
You must specify a path on the local computer, such as C:\\Project\\HTML. If the specified path does not exist, then Iisvdir.vbs creates the path.
- /s Computer
Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
- /u [Domain\]User
Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
- /p Password
Specifies the password of the user account specified in the /u parameter. If you omit this parameter, the script prompts you for the password and obscures the text you type.
- /?
Displays help at the command prompt.
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
The following examples show how to use iisvdir /create in specific situations.
To create a virtual directory at the root of the Web site
The following command creates a virtual directory called Insurance at the root of the Finance Web site on the local computer. It associates the directory with content currently stored in the C:\Projects\Insurance\Html directory.
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 following command creates a virtual directory called Updates on the Finance Web site of a remote server, Svr01. It uses the /s command to identify the server computer, and the /u and /p commands to run Iisvdir.vbs with the permissions of the user's Administrator account.
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
This example uses an artifact of virtual directories to hide the contents of a physical directory so that it cannot be seen on the Internet or an intranet. The command creates a virtual directory with the same name as a physical directory in the same virtual path of a Web site. As a result, Web users cannot see the contents of the 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
Deletes virtual directories from the Web sites on servers running Windows Server 2003 with Internet Information Services (IIS) 6.0.
Syntax
iisvdir[.vbs] /delete Website[/VirtualPath]/Name[/s Computer [/u [Domain**\]User [/p** Password]]]
Parameters
- WebSite
Required. Specifies the descriptive name or metabase path of the Web site.
- VirtualPath
Specifies the path to the virtual directory. This parameter is required when the virtual directory is not located at the root of the Web site.
- Name
Required. Specifies the name of the virtual directory.
- /s Computer
Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
- /u [Domain\]User
Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
- /p Password
Specifies the password of the user account specified in the /u parameter. If you omit this parameter, the script prompts you for the password and obscures the text you type.
- /?
Displays help at the command prompt.
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
The following examples show how to use iisvdir /delete in specific situations.
To delete a virtual directory
The following command deletes the Insurance virtual directory from the Finance Web site on the local server. As a result, the Insurance directory and all actual and virtual subdirectories of the Insurance directory are deleted.
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
Displays the virtual directories of Web sites on servers running Windows Server 2003 with Internet Information Services (IIS) 6.0.
Syntax
iisvdir /query WebSite[/VirtualPath] [/s Computer [/u [Domain**\]User [/p** Password]]]
Parameters
- WebSite
Required. Specifies the descriptive name or metabase path of the Web site.
- VirtualPath
Specifies the path to a directory within the Web site. The query lists all virtual directories under the specified directory. Without this parameter, Iisvdir.vbs lists the virtual directories at the root of the Web site.
- /s Computer
Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. By default, the script runs on the local computer.
- /u [Domain\]User
Runs the script with the permissions of the specified user account. This account must be a member of the Administrators group on the remote computer. By default, the script runs with the permissions of the current user of the local computer.
- /p Password
Specifies the password of the user account specified in the /u parameter. If you omit this parameter, the script prompts you for the password and obscures the text you type.
- /?
Displays help at the command prompt.
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
The following examples show how to use iisvdir /query in specific situations.
To display the virtual directories of a Web site
The following command displays the virtual directories at the root of the Finance 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
The following command displays the virtual directories that are subdirectories of the Insurance virtual directory on the Finance Web site. The command specifies the Insurance directory by using its virtual path.
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 |
|
Code or program output |
See Also
Concepts
Iisapp.vbs: IIS application query script
Iisback.vbs: IIS backup management script
Iiscnfg.vbs: IIS configuration script
Iisext.vbs: IIS Web service extension script
Iisftp.vbs: IIS FTP site management script
IISFtpdr.vbs: IIS FTP directory script
Iisweb.vbs: IIS Web site management script
Command-line reference A-Z
Command shell overview