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 topOverview
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:
back to the topTo 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 PathSiteName [/b Port] [/i IPAddress] [/d HostHeader] [/dontstart] [/s Computer [/u [Domain\]User /p Password]]
The parameters used by
Iisweb /create are described as follows:
- Path: Specifies the location of content files for the Web site on the
local computer. If the specified path does not exist, Iisweb creates it.
- SiteName: A required parameter that specifies the name of the Web site.
- /b Port: Specifies a TCP port number for the Web site. The default port
is 80.
- /i IPAddress: 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 HostHeader: 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 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 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 "My Site" /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 WebSite [WebSite...] [/s Computer [/u [Domain\]User/p Password]]
The parameters used by
Iisweb /delete are described as follows:
- WebSite: 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 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 that is specified in
the /u parameter.
The following sample command line deletes a Web site configuration named My
Site on the local computer:
back to the
topTo 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 WebSite [WebSite...] [/s Computer [/u [Domain\]User /p Password]]
The parameters used by
iisweb /query are described as follows:
- WebSite: 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 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 that is specified in
the /u parameter.
The following sample command line displays the Web sites on the local
computer:
back to the
topTo 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 WebSite [/Virtual Path]Name Physical Path [/s Computer [/u [Domain\] User /p Password]]
The parameters used by
iisvdir /create are described as follows:
- WebSite: A required parameter that specifies the unique descriptive name
or metabase path of the Web site.
- Virtual Path: 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.
- Name : 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.
- Physical Path: 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 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 that is specified in
the /u parameter.
The following sample command line creates the Projects virtual directory at
the root of the "Marketing" 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
topTo 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 WebSite [/Virtual Path]Name [/s Computer [/u [Domain\]User /p Password]]
The parameters used by
iisvdir /delete are described as follows:
- WebSite: A required parameter that specifies the unique descriptive name
or metabase path of the Web site.
- Virtual Path: 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.
- Name : 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 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 that is specified in
the /u parameter.
The following sample command line deletes the Projects virtual directory
from the "Marketing" 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