Introduction to iisvdir.vbs IIS Virtual Directory Management Script

Time:2019-5-24

IIS manager also creates and deletes virtual directories by calling iisvdir. vbs. We can execute iisvdir. VBS scripts from the command line

1) Create virtual directories:
cscript c:\windows\system32\iisvdir.vbs [/s server] [/u username /p password] /create [virtualRoot] Alias PhysicalPath
2) Delete virtual directories:
1cscript c:\windows\system32\iisvdir.vbs [/s server] [/u username /p password] /delete [virtualRoot]/Alias
3) View all subdirectories under the specified virtual directory:
1cscript c:\windows\system32\iisvdir.vbs [/s server] [/u username /p password] /query virtualRoot

Applications: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1, Windows Server 2003 with SP2
Iisvdir.vbs: IIS Virtual Directory Script
Create and delete virtual directories of websites on a server running Windows Server 2003 with Internet Information Service (IIS) 6.0.
To view the command syntax, click the following command:

•iisvdir /create
•iisvdir /delete
•iisvdir /query
iisvdir /create

Create a virtual directory of the website on a server running Windows Server 2003 with Internet Information Service (IIS) 6.0.
grammar
iisvdir[.vbs] /create WebSite[/VirtualPath] Name PhysicalPath [/sComputer [/u [Domain\]User [/p Password]]]
parameter
WebSite
Necessary. Specify the descriptive name of the Web site or configure the database path.
VirtualPath
Specify the path of the virtual directory within the site. The virtual path does not contain the name of the virtual directory.
This parameter places the virtual directory under the subdirectory of the website. By default, the virtual directory will be added to the root directory of the site. All directories in the virtual path must already exist on the website.
Name
Necessary. Specify the name of the virtual directory. You can choose any name.
PhysicalPath
Necessary. Specify the physical directory of the virtual directory.
A path must be specified on the local computer, such as C: Project HTML. If the specified path does not exist, Iisvdir. VBS creates the path.
/s Computer
Run the script on the specified remote computer. Type the computer name or IP address without backslash. By default, the script runs on the local computer.
/u [Domain\]User
Run the script with the privileges of the specified user account. The account must be a member of the Administrators group on the remote computer. By default, the script runs with the privileges of the current user on the local computer.
/p Password
Specifies the password for the user account specified in the / u parameter. If you ignore this parameter, the script prompts you to enter a password without displaying the text you typed.
/?
Display help at a command prompt.

Notes

To execute this process, you must be a member of the Administrators group on your local computer, or you must be delegated the appropriate privileges. If the computer has joined a domain, members of the Domain Admins group may perform the process. As the safest operation, consider using “Running Mode” to execute this process.

The WebSite (or WebSite/VirtualPath) Name and Hysical Path parameters must always appear in the order specified on the command line. Otherwise, Iisvdir. VBS will not interpret the information correctly.

When using Iisvdir.vbs to create a new virtual directory, only the basic attributes required to create a site and identify its content are specified. The default attributes used by Iisvdir. VBS are the same as those used by IIS when creating a new virtual directory. It conforms to the rules of inheritance attributes. To configure more advanced properties of the site, use IIS Manager.

* Virtual directory name (Name) does not require unique. However, when the name of the virtual directory and the physical directory included in the website is the same, the content of the physical directory will not be visible on the Internet.

Example

The following example shows how to use iisvdir/create in a specific situation.

Create a virtual directory under the root directory of the site

The following command creates a virtual directory named Insurance under the root directory of the Finance Web site on the local computer. It associates the directory with the content currently stored in the C: Projects Insurance Html directory.

Copy codeThe code is as follows:
iisvdir /create Finance Insurance c:\projects\insurance\html

In response, Iisvdir.vbs displays the following message, indicating that the command has been successfully executed and showing 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

WebSite, Name, and Hysical Path parameters must appear in the order specified in the command. The following command is the same as the previous one, except that the order of parameters is different:
iisvdir /create c:\projects\insurance\html Finance Insurance

The command failed, the parameters were interpreted incorrectly, and Iisvdir.vbs would report that a Web site named “c:” could not be found.

Create a virtual directory in the website path

The following command creates a virtual directory named Updates on the Finance Web site of the remote server Svr01. It uses the / s command to identify the server computer and / u and / P commands to run Iisvdir. VBS with user administrator account privileges.

This command creates a new virtual directory as a subdirectory of the Finance/Insurance directory. This command identifies the Finance Web site using the configuration database path W3SVC/1509060625. It specifies the virtual path Finance/Insurance by appending it to the website name.

Finally, the command associates the Updates directory with the content stored on the remote computer C: Newstuff Web.
iisvdir /createW3SVC/1509060625/InsuranceUpdatesC:\Newstuff\Web/s svr01/u Admin01/p [email protected]#rD2
In response, Iisvdir.vbs displays the following message, indicating that the command has been successfully executed and showing 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 issuing the command. If the site or its subdirectories do not exist, the command may fail.
In addition, the Insurance subdirectory is a virtual directory. Iisvdir. VBS can be used to create virtual paths in real or virtual directories.

Create virtual directories to hide physical directories

This example uses unnatural signals from virtual directories to hide the contents of physical directories, so that they will not be seen on the Internet or Intranet. This command creates a virtual directory with the same name as the physical directory in the same virtual path of the Web site. In this way, Web users will not be able to see the contents of the physical directory.
Although this method does not protect the security of physical directories, it provides a safeguard against privacy.
The following command creates a virtual directory named Personnel under the root directory of the Finance Web site. The virtual directory is related to the physical directory D: II Stest Personnel, which contains public information about Finance Department personnel.
iisvdir /create Finance Personnel D:\IIStest\Personnel
In response, Iisvdir.vbs displays the following message, indicating that the command has been successfully executed and showing 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

With this command, the site will have a physical directory and a virtual directory named Personnel. Users visiting the Finance Web site will see the contents of the Personnel virtual directory. These users can’t see the contents of the Personnel physical directory.

iisvdir /delete

Delete the virtual directory of the website on the server running Windows Server 2003 with Internet Information Service (IIS) 6.0.
grammar
iisvdir[.vbs] /delete Website[/VirtualPath]/Name[/s Computer [/u [Domain\]User [/p Password]]]
parameter
WebSite
Necessary. Specify the descriptive name of the Web site or configure the database path.
VirtualPath
Specify the path to the virtual directory. This parameter is required when the virtual directory is not located in the root directory of the website.
Name
Necessary. Specify the name of the virtual directory.
/s Computer
Run the script on the specified remote computer. Type the computer name or IP address without backslash. By default, the script runs on the local computer.
/u [Domain\]User
Run the script with the privileges of the specified user account. The account must be a member of the Administrators group on the remote computer. By default, the script runs with the privileges of the current user on the local computer.
/p Password
Specifies the password for the user account specified in the / u parameter. If you ignore this parameter, the script prompts you to enter a password without displaying the text you typed.
/?
Display help at a command prompt.
Notes
To execute this process, you must be a member of the Administrators group on your local computer, or you must be delegated the appropriate privileges. If the computer has joined a domain, members of the Domain Admins group may perform the process. As the safest operation, consider using “Running Mode” to execute this process.

* Do not use Iisvdir.vbs to delete websites. If this is done, the site will still be listed, but it will be partially deleted and not functioning properly. To delete the website through Iisvdir. VBS or correct the incorrect deletion of the website, use the Iisweb. vbs: IIS website management script.

Example

The following example shows how to use iisvdir/delete in a specific situation.

Delete virtual directories

The following command deletes the Insurance virtual directory from the Finance Web site of the local server. As a result, all actual and virtual subdirectories of the Insurance directory and Insurance directory will be deleted.
iisvdir /deleteFinance/Insurance
In response, Iisvdir. VBS displays the following message indicating that the command has been successfully executed. Note that Iisvdir. VBS does not require confirmation before deleting a directory or its subdirectories.
Web directory Finance/ROOT/Insurance has been DELETED.
iisvdir /query
Display the virtual directory of the website on the server running Windows Server 2003 with Internet Information Service (IIS) 6.0.
grammar
iisvdir /query WebSite[/VirtualPath] [/s Computer [/u [Domain\]User [/p Password]]]
parameter
WebSite
Necessary. Specify the descriptive name of the Web site or configure the database path.
VirtualPath
Specify the path of the directory within the site. This query lists all virtual directories under the specified directory. If this parameter is not used, Iisvdir. VBS lists the virtual directories under the site’s root directory.
/s Computer
Run the script on the specified remote computer. Type the computer name or IP address without backslash. By default, the script runs on the local computer.
/u [Domain\]User
Run the script with the privileges of the specified user account. The account must be a member of the Administrators group on the remote computer. By default, the script runs with the privileges of the current user on the local computer.
/p Password
Specifies the password for the user account specified in the / u parameter. If you ignore this parameter, the script prompts you to enter a password without displaying the text you typed.
/?
Display help at a command prompt.
Notes
To execute this process, you must be a member of the Administrators group on your local computer, or you must be delegated the appropriate privileges. If the computer has joined a domain, members of the Domain Admins group may perform the process. As the safest operation, consider using “Running Mode” to execute this process.

The “query” operation displays only virtual directories. The physical directory in the website or path is not displayed.

The “query” operation displays only the virtual directory under the website root directory or the specified subdirectory. It does not search recursively.

Example
The following example shows how to use iisvdir/query in specific situations.
Display virtual directories of websites
The following command will display the virtual directory under the root directory of the Finance Web site:

Copy codeThe code is as follows:
iisvdir /query Finance

In response, Iisvdir. VBS displays two virtual directories under the Finance root directory. Note that these directories will appear in the Finance root directory, even if their physical location is irrelevant.
This display does not include virtual directories as site subdirectories. The process of finding subdirectories is described in the following example, “Display virtual subdirectories”.

 Alias                    Physical Root ============================================================================== /Personnel               D:\Corpdir\FinanceWeb\People /Insurance               C:\Marketing\Insurance\HTMFiles
Display virtual subdirectories
The following command will show some virtual directories, which are subdirectories of the Insurance virtual directory on the Finance Web site. This command specifies the Insurance directory by using its virtual directory path.
iisvdir /query Finance\Insurance
This command displays the Current subdirectory of the Insurance virtual directory.

 Alias                    Physical Root ============================================================================== /Current                 C:\Insurance\Monthly\200204
Notes
* Iisvdir.vbs can perform the same operations provided in IIS Manager. Any tool can be used to view and manage virtual directories.

* The computer issuing the command must be running Windows XP or Windows Server 2003 operating system. The user must be a member of the Administrators group on the computer affected by the command.

The computer affected by the command must be a server running Windows Server 2003 with Internet Information Service (IIS) 6.0.

When connecting to IIS services on a specified computer, Iisvdir.vbs displays the “Connecting to Server” message. This message occurs every time Iisback. VBS is used, whether running the command on a local or remote computer.

Use quotation marks to enclose path elements that contain spaces. Include only elements with spaces, excluding the entire path. For example, you should type “Default Web Site” / IISAdmin instead of “Default Web Site / IISAdmin”.

Recommended Today

Learn a Linux command every day (62): Ping

Yesterday’s recommendation:Learn a Linux command every day (61): WGet Command introduction The ping command is used to test the network connectivity between hosts. Ping is a simple way to send network data to and receive network data from another computer on the network. It is usually used to test whether it can be accessed through […]