Microsoft KB Archive/816568

= HOW TO: Manage Web Sites and Web Virtual Directories by Using Command-Line Scripts in IIS 6.0 =

Article ID: 816568

Article Last Modified on 12/3/2007

-

APPLIES TO


 * Microsoft Windows Server 2003, 64-Bit Datacenter Edition
 * Microsoft Windows Server 2003, Enterprise x64 Edition
 * Microsoft Windows Server 2003, Datacenter Edition (32-bit x86)
 * Microsoft Windows Server 2003, Enterprise Edition (32-bit x86)
 * Microsoft Windows Server 2003, Standard Edition (32-bit x86)
 * Microsoft Windows Server 2003, Web Edition
 * Microsoft Internet Information Services 6.0
 * Microsoft Windows Small Business Server 2003 Standard Edition
 * Microsoft Windows Small Business Server 2003 Premium Edition

-





For a Microsoft Windows 2000 version of this article, see 308622.



IN THIS TASK

 * SUMMARY
 * Overview
 * To Create and Manage Web Sites
 * To Create a New Web Site
 * To Delete a Web Site
 * To List Web Sites
 * To Create and Manage Web Virtual Directories
 * To Create a New Web Virtual Directory
 * To Delete a Web Virtual Directory
 * REFERENCES



SUMMARY
This article describes how to use command-line scripts to perform some common administrative tasks that pertain to the management of Web sites and Web virtual directories in Internet Information Services (IIS) 6.0. It also describes how to use the Iisweb.vbs script to create and delete Web sites, and how to use the Iisvdir.vbs script to create and delete Web virtual directories.

back to the top

Overview
IIS 6.0 includes several supported command-line scripts that use the Windows Management Instrumentation (WMI) provider to configure and manage IIS metabase configurations on local or remote computers that are running IIS. You can use these scripts to automate tasks, remotely administer sites and resources, and take advantage of batch files to create and manage objects. Microsoft supports the command-line scripts that are included in IIS, assuming that those scripts are not modified. If you want to modify a supported script, save it under a new file name so that the original script remains unmodified.

The scripts are located in the %SystemRoot\System32 folder. You must be a member of the Administrators group on the local computer to run scripts and executables, or you must be delegated the appropriate permissions. To open a command prompt to perform any of the tasks that are described in this article, follow these steps:  Click Start, click Run, type cmd in the Open box, and then click OK. Type the following line, and then press ENTER:

cd %systemroot%\system32



back to the top

To Create and Manage Web Sites
To create and manage Web sites by using the Iisweb.vbs script, use the following methods.

To Create a New Web Site
To create a new Web site configuration, use the iisweb /create command. This command does not create content, but it sets up the folder structure and some IIS configuration files. When you use Iisweb.vbs to create a new Web site, you specify only the basic properties that are required to create the site and identify its contents. To configure more advanced properties, use IIS Manager.

The Iisweb /create command uses the following syntax:

iisweb /create   [/b  ] [/i  ] [/d  ] [/dontstart] [/s  [/u [ \]  /p  ]]

The parameters used by Iisweb /create are described as follows:
 *  : Specifies the location of content files for the Web site on the local computer. If the specified path does not exist, Iisweb creates it.
 *  : A required parameter that specifies the name of the Web site.
 * /b : Specifies a TCP port number for the Web site. The default port is 80.
 * /i : Specifies an IP address for the Web site. The default setting, All Unassigned, assigns to the site all the IP addresses on the computer that are not assigned to other sites.
 * /d : Specifies the host header name for the Web site. By default, the site does not have a host header name and must be identified by its IP address or port number.
 * /dontstart: This parameter specifies that the Web site will not start automatically after it is created.
 * /s : 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 [ \] : 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 : Specifies the password of the user account that is specified in the /u parameter.

The following sample command line creates a Web site configuration named My Site on the local computer. The source files are located in the C:\MySource folder, and the host header name is specified:

iisweb /create C:\MySource &quot;My Site&quot; /d www.mywebsite.com /dontstart

back to the top

To Delete a Web Site
To delete a Web site configuration, use the iisweb /delete command. This command is useful if you plan to move the site to a new Uniform Resource Locator (URL) or server, or if you want to remove it completely. The content of the site is not affected after you use this command, but the site is inaccessible to users.

The iisweb /delete command uses the following syntax:

iisweb /delete  [ ...] [/s   [/u [ \] /p  ]]

The parameters used by Iisweb /delete are described as follows:
 *  : A required parameter that specifies the unique descriptive name or metabase path of the Web site. If more than one Web site uses the same descriptive name, you must use the metabase path to identify the Web site.
 * /s : 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 [ \] : 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 : Specifies the password of the user account that is specified in the /u parameter.

The following sample command line deletes a Web site configuration named My Site on the local computer:

iisweb /delete &quot;My Site&quot;

back to the top

To List Web Sites
To query or list Web sites, use the iisweb /query command. This command is useful when you want to check the status or check the properties of Web sites on a local or remote computer.

The iisweb /query command uses the following syntax:

iisweb /query  [ ...] [/s   [/u [ \]  /p  ]]

The parameters used by iisweb /query are described as follows:
 *  : Limits the query to the specified Web site. Use the unique descriptive name or metabase path of the Web site. If you omit this parameter, all Web sites on the computer are included in the display.
 * /s : 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 [ \] : 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 : Specifies the password of the user account that is specified in the /u parameter.

The following sample command line displays the Web sites on the local computer:

iisweb /query

back to the top

To Create and Manage Web Virtual Directories
To create and manage Web virtual directories by using the iisvdir.vbs script, use the following methods.

To Create a New Web Virtual Directory
To create a new Web virtual directory, use the iisvdir /create command. This command does not create content, but it sets up the virtual directory structure and IIS configuration files. When you use Iisvdir.vbs to create a new Web virtual directory, you specify only the basic properties that are required to create the site and identify its contents. To configure more advanced properties, use IIS Manager.

The iisvdir /create command uses the following syntax:

iisvdir /create  [/ ]  [/s   [/u [ \]   /p  ]]

The parameters used by 'iisvdir /create' are described as follows:
 *  : A required parameter that specifies the unique descriptive name or metabase path of the Web site.
 *  : Specifies a path to the virtual directory in the Web site. This parameter is required if the virtual directory is not located at the root of the Web site.
 *  : A required parameter that specifies a name for the virtual directory. Virtual directory names do not have to be unique. However, when a Web site includes a virtual directory and a physical directory with the same name, the physical directory is not visible on the Internet.
 * : Specifies a physical folder where the content for the virtual directory resides on the local computer. If the specified folder does not exist, Iisvdir creates it.
 * /s : 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 [ \] : 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 : Specifies the password of the user account that is specified in the /u parameter.

The following sample command line creates the Projects virtual directory at the root of the &quot;Marketing&quot; Web site on the local computer. It associates the directory with content that is currently stored in the C:\Corp\Projects\Web folder:

iisvdir /create Marketing Projects c:\corp\projects\web

back to the top

To Delete a Web Virtual Directory
To delete a Web virtual directory, use the iisvdir /delete command.

The iisvdir /delete command uses the following syntax:

iisvdir /delete  [/ ]  [/s   [/u [ \]  /p  ]]

The parameters used by 'iisvdir /delete' are described as follows:
 *  : A required parameter that specifies the unique descriptive name or metabase path of the Web site.
 *  : Specifies a path to the virtual directory in the Web site. This parameter is required if the virtual directory is not located at the root of the Web site.
 *  : A required parameter that specifies a name for the virtual directory. Virtual directory names do not have to be unique. However, when a Web site includes a virtual directory and a physical directory with the same name, the physical directory is not visible on the Internet.
 * /s : 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 [ \] : 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 : Specifies the password of the user account that is specified in the /u parameter.

The following sample command line deletes the Projects virtual directory from the &quot;Marketing&quot; Web site on the local computer. Note that all virtual subdirectories of the Projects virtual directory are also deleted.

iisvdir /delete Marketing/Projects

back to the top

