Deleting Web Virtual Directories Using Iisvdir.vbs

Applies To: Windows Server 2003, Windows Server 2003 R2, Windows Server 2003 with SP1

You can use the command-line script iisvdir.vbs, which is stored in systemroot\System32, to delete a virtual directory on local or remote computers running a member of the Windows Server 2003 family with IIS 6.0. This command does not create or destroy content, but simply deletes the virtual directory structure.

You should not use this command to delete Web sites, as the sites may still be listed, but partially disabled. To delete a Web site, use Deleting Web Sites Using Iisweb.vbs

Important

You must be a member of the Administrators group on the local computer to run scripts and executables. As a security best practice, log on to your computer by using an account that is not in the Administrators group, and then use the runas command to run your script or executable as an administrator. At a command prompt, type runas /profile /User:MyComputer</STRONG>Administrator cmd to open a command window with administrator rights and then type cscript.exe ScriptName (include the script's full path and any parameters).

This topic includes the following information:

  • Syntax: The order in which you type a command and any arguments and options that follow it.

  • Parameters: The values that are given to variables in the command.

  • Examples: Sample code and an explanation of the results.

Syntax

iisvdir /delete WebSite[/VirtualPath] Name [/s Computer [/u [Domain\]User**/p** Password]]

Parameters

WebSite

Required. Specifies the descriptive name, or the metabase path, of the Web site.

VirtualPath

Specifies a path, if necessary, to the virtual directory within the Web site. This parameter is required when the virtual directory is not located at the root of the Web site.

Name

Required. 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 will not be visible on the Internet.

/s Computer

Runs the script on the specified remote computer. Type the computer name or IP address without backslashes. The default is 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.

Examples

Example 1:

The following example deletes the "Insurance" virtual directory from the "Finance" Web site on the local computer. As a result, not only is the "Insurance" directory deleted, but all of the physical and virtual subdirectories are deleted as well.

iisvdir /delete Finance/Insurance

The /s, /u, and /p parameters are unnecessary in this instance because the default computer is local and the user running the command must be logged on as an administrator.

In response, iisvdir displays the following message:

Connecting to server ...Done.

Web directory Finance/Insurance has been DELETED.

Example 2:

The following example deletes the "Updates" virtual subdirectory called on the "Finance" Web site of the remote computer. 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.

The example also uses the /s parameter to identify the remote computer, as well as the /u and /p parameters to run iisvdir.vbs with the permissions of the user's administrator account.

iisvdir /delete W3SVC/1509060625/Insurance/Updates /s SVR01 /u Admin01 /p p@SSw#rD2

In response, iisvdir displays the following message:

Connecting to server ...Done.

Web directory Finance/Insurance/Updates has been DELETED.