Iisvdir.vbs IIS Virtual Directory Administration script usage _vbs

Source: Internet
Author: User
Tags require metabase

IIS Manager also implements the creation and deletion of virtual directories by calling Iisvdir.vbs. We can execute the iisvdir.vbs script by command line

1 Create the virtual directory:
cscript C:\windows\system32\iisvdir.vbs [/s server] [/u username/p password]/create [virtualroot] Alias PhysicalPath
2 Delete virtual directory:
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

Applied to: 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 for a Web site on a server running Windows Server 2003 with Internet Information Services (IIS) 6.0.
To view the command syntax, click the following command:

iisvdir/create
Iisvdir/delete
Iisvdir/query
Iisvdir/create

Create a virtual directory for a Web site on a server running Windows Server 2003 with Internet Information Services (IIS) 6.0.
Grammar
Iisvdir[.vbs]/create Website[/virtualpath] Name physicalpath [/scomputer [/U [domain\]user [/P Password]]]
Parameters
WebSite
Necessary. Specifies the descriptive name or metabase path of the Web site.
VirtualPath
Specifies the path to the virtual directory within the Web site. The virtual path does not contain the name of the virtual directory.
This parameter places the virtual directory under the subdirectory of the Web site. By default, the virtual directory is added to the root directory of the Web site. All directories in the virtual path must already exist on the site.
Name
Necessary. Specifies the name of the virtual directory. You can select any name.
PhysicalPath
Necessary. Specifies the physical directory of the virtual directory.
You must specify a path on the local computer, such as C:\Project\HTML. If the specified path does not exist, Iisvdir.vbs creates the path.
/s Computer
Runs the script on the specified remote computer. Type the name or IP address of the computer without the backslash. By default, scripts run on the local computer.
/u [domain\]user
Runs the script with the permissions 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 permissions of the current user of the local computer.
/P Password
Specifies the password for the user account specified in the/u parameter. If you omit this argument, the script prompts you for a password and does not display the text you typed.
/?
Displays help at the command prompt.

Comments

• To perform this procedure, you must be a member of the Administrators group on the local computer, or you must be delegated the appropriate permissions. Members of the domain Admins group may perform this procedure if the computer is already joined to a domain. As the safest operation, consider using run as to perform this procedure.

The website (or Website/virtualpath) Name and PhysicalPath parameters must always appear in the order specified on the command line. Otherwise, Iisvdir.vbs will not be able to interpret the information correctly.

• When using iisvdir.vbs to create a new virtual directory, specify only the basic attributes required to create a site and identify its content. The default properties used by Iisvdir.vbs are the same as the default properties used when IIS establishes a new virtual directory, and it conforms to the rules for inheriting properties. To configure more advanced properties for your site, use IIS Manager.

• Virtual directory name (name) does not require unique. However, when the Web site includes a virtual directory and a physical directory with the same name, you will not be able to see the contents of the physical directory on the Internet.

Example

The following example shows how to use iisvdir/create in a particular case.

Create a virtual directory under the root directory of a Web 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 what is currently stored in the C:\Projects\Insurance\Html directory.

Copy Code code as follows:

Iisvdir/create Finance Insurance c:\projects\insurance\html

In response, Iisvdir.vbs displays the following message indicating that the command was executed successfully and that the basic properties of the new virtual directory are displayed:

Connecting to server ... Done.virtual Path = finance/insurance ROOT = c:\projects\insurance\html Metabase Path = w3svc/1509060625/root/in Surance

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

The command failed with an error explaining the argument and Iisvdir.vbs could not find a Web site named "C:".

Create a virtual directory in a Web site path

The following command creates a virtual directory named Updates on the Finance Web site on the remote server Svr01. It uses the/s command to identify the server computer and uses the/U and/P commands to run iisvdir.vbs through the User Administrator account permissions.

This command creates a new virtual directory as a subdirectory of the Finance/insurance directory. This command uses the Finance Web site's metabase path w3svc/1509060625 to identify the site. It indicates the virtual path finance/insurance by attaching it to the site name.

Finally, the command associates the Updates directory with what is stored in the remote computer C:\Newstuff\Web.
iisvdir/createw3svc/1509060625/insuranceupdatesc:\newstuff\web/s svr01/u admin01/p p@SSw#rD2
In response, Iisvdir.vbs displays the following message indicating that the command was executed successfully and that the basic properties of the new virtual directory are displayed:


Connecting to server ... Done.virtual Path = finance/insurance/updates ROOT = C:\Newstuff\Web Metabase Path = W3svc/1509060625/root/insur Ance/updates

In this example, the Finance Web site and its Insurance subdirectories already exist on the Svr01 IIS server before the command is issued. If the Web site or its subdirectories do not exist, the command may fail.
In addition, the Insurance subdirectory is a virtual directory. You can use Iisvdir.vbs to create virtual paths within the actual directory or virtual directory.

Create a virtual directory to hide the physical directory

This example uses unnatural signals from the virtual directory to hide the contents of the physical directory so that it will not be visible on the Internet or on an Intranet. This command creates a virtual directory with the same name as the physical directory in the same virtual path as the Web site. This way the WEB user will not see the contents of the physical directory.
Although this method does not secure the physical directory, 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:\IIStest\Personnel that 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 was executed successfully and that the basic properties of the new virtual directory are displayed:


Connecting to server ... Done.virtual Path = Finance/personnel ROOT = D:\IIStest\Personnel Metabase Path = W3svc/1509060625/root/personne L

With this command, the site will have a physical directory and a virtual directory named personnel. Users who visit the Finance Web site will see the contents of the Personnel virtual directory. These users do not see the contents of the personnel physical directory.

Iisvdir/delete

Deletes a Web site's virtual directory on a server running Windows Server 2003 with Internet Information Services (IIS) 6.0.
Grammar
Iisvdir[.vbs]/delete website[/virtualpath]/name[/s Computer [/u [domain\]user [/P Password]]]
Parameters
WebSite
Necessary. 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 in the root directory of the Web site.
Name
Necessary. Specifies the name of the virtual directory.
/s Computer
Runs the script on the specified remote computer. Type the name or IP address of the computer without the backslash. By default, scripts run on the local computer.
/u [domain\]user
Runs the script with the permissions 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 permissions of the current user of the local computer.
/P Password
Specifies the password for the user account specified in the/u parameter. If you omit this argument, the script prompts you for a password and does not display the text you typed.
/?
Displays help at the command prompt.
Comments
• To perform this procedure, you must be a member of the Administrators group on the local computer, or you must be delegated the appropriate permissions. Members of the domain Admins group may perform this procedure if the computer is already joined to a domain. As the safest operation, consider using run as to perform this procedure.

• Do not use iisvdir.vbs to delete sites. If you do this, the site will still be listed, but it will be partially deleted and not functioning properly. To remove a Web site by iisvdir.vbs, or to correct an incorrect deletion of the site, use the Iisweb.vbs:IIS Web Site administration script.

Example

The following example shows how to use iisvdir/delete in a particular case.

Delete virtual directory

The following command deletes the Insurance virtual directory from the Finance Web site on the local server. As a result, all actual and virtual subdirectories of the Insurance directory and the Insurance directory will be deleted.
Iisvdir/deletefinance/insurance
As the response, Iisvdir.vbs displays the following message indicating that the command was executed successfully. Please note that Iisvdir.vbs does not require confirmation before deleting the directory or its subdirectories.
Web directory finance/root/insurance has been DELETED.
Iisvdir/query
Displays the virtual directory of the Web site on a server 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 the directory within the Web site. This query lists all the virtual directories under the specified directory. If you do not use this parameter, iisvdir.vbs lists the virtual directories that are under the root directory of the Web site.
/s Computer
runs the script on the specified remote computer. Type the name or IP address of the computer without the backslash. By default, scripts run on the local computer.
/u [domain\]user
runs the script with the permissions 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 permissions of the current user of the local computer.
/P Password
Specifies the password for the user account specified in the/u parameter. If you omit this argument, the script prompts you for a password and does not display the text you typed.
/? The
displays help at a command prompt.
Note
• To perform this procedure, you must be a member of the Administrators group on the local computer, or you must be delegated the appropriate permissions. Members of the domain Admins group may perform this procedure if the computer is already joined to a domain. As the safest operation, consider using run as to perform this procedure.

• This "query" operation displays only virtual directories. The physical directory in the Web site or path is not displayed.

• The query operation displays only virtual directories in the root directory of the Web site or in a specified subdirectory. It does not perform a recursive search.

Example
The following example shows how to use iisvdir/query in a particular case.
Show virtual directories for Web sites
The following command displays the virtual directory under the root directory of the Finance Web site:

Copy Code code as follows:

Iisvdir/query Finance

In response, Iisvdir.vbs will display two virtual directories under the Finance root directory. Note that these directories will appear under the Finance root directory, even if their physical location is irrelevant.
The display does not include a virtual directory as a site subdirectory. The procedure for locating subdirectories is described in the following example, "displaying virtual subdirectories."

 Alias                     Physical Root ==============================================================================/ personnel               D:\Corpdir\ financeweb\people/insurance                C:\Marketing\Insurance\HTMFiles
Show Virtual subdirectories
The following command displays virtual directories that are subdirectories of the Insurance virtual directories on the Finance Web site. The command will specify 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 ==============================================================================/Cur Rent C:\Insurance\Monthly\200204
Comments
Iisvdir.vbs can perform the same operations that are provided in IIS Manager. You can use either tool to view and manage virtual directories.

• The computer that issued the command must be running Windows XP or the Windows Server 2003 operating system. The user must be a member of the Administrators group on the computer to which the command affects.

• The computer that the command affects must be a server running Windows Server 2003 with Internet Information Services (IIS) 6.0.

• When connecting to the IIS service on the specified computer, Iisvdir.vbs will display the "Connecting to Server" message. Each time you use Iisback.vbs, this message appears regardless of whether you are running the command on a local or remote computer.

• Use quotes to enclose path elements that contain spaces. Enclose only elements with spaces, excluding the entire path. For example, you should type the default Web Site/iisadmin instead of the default Web Site/iisadmin.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.