Create and Delete Virtual Directories in IIS 4.0

ID: Q188954


The information in this article applies to:
  • Microsoft Internet Information Server version 4.0


SUMMARY

CrtVDirD.exe is a self extracting executable that contains a Visual C++ sample that demonstrates how to add and delete Virtual Directories and Applications in Internet Information Server (IIS) 4.0 using the IIS Admin Base Object and the IWamAdmin Object. The sample was built with Visual C++ 5.0.


MORE INFORMATION

The following files are available for download from the Microsoft Download Center. Click the file names below to download the files:

Crtvdird.exe
For more information about how to download files from the Microsoft Download Center, please visit the Download Center at the following Web address
http://www.microsoft.com/downloads/search.asp
and then click How to use the Microsoft Download Center. CrtVDir: uses the IIS Admin Base Object to add or remove Virtual Directories to a Web Server. It uses the IWamAdmin object to create or remove Applications.

NOTE: It is necessary for a virtual directory to exist before creating an application.

Usage:

To create a Virtual Directory (CD):
CrtVDir.exe CD <path> <name> [<permissions>] [<site>]
To remove a Virtual Directory (RD):
CrtVDir.exe RD <name> [<site>]
To create an Application (CA):
CrtVDir.exe CA <metabasepath> <INPROC|OOP>
To remove an Application (RA):
CrtVDir.exe RA <metabasepath>
Params:

Path - Physical path to which the Virtual Directory refers.

Name - Name for virtual directory.

Metabasepath - Metabasepath is the full metabase path to the relevant key. Note that if the path you enter does not begin with a "/" character, ISAPIReg prepends "/LM/" to the path.

Permissions - see later reference in article.

Site - Defaults to "1" if not supplied.

INPROC|OOP - Application runs in-process of out-of-process.

Permissions - The following values are for the common permission flags. These may be added together to form a combination of permissions for the virtual root:
1 = Read Access
2 = Write Access
4 = Execute Access (including Script)
512 = Script Access
Samples:

To obtain help on the command line parameters:
C:> CrtVDir.exe
To create NewVDir Virtual Directory pointing to D:\InetPub\wwwroot\NewVDir:
C:> CrtVDir.exe CD D:\InetPub\wwwroot\NewVDir NewVDir
To remove the same directory:
C:> CrtVDir.exe RD NewVDir
To create an application:
C:> CrtVDir.exe CA w3svc/1/root/NewVDir INPROC
To remove an application:
C:> CrtVDir.exe RA w3svc/1/root/NewVDir
Metabase Issues:

The metabase is a secure object, and requires sufficient permissions to open and use. Any application that uses this code to access the metabase must run in a context with appropriate permissions.

The header file for IWamAdmin was not included in the Internet Information Server (IIS) 4.0 Software Development Kit (SDK). You can get the file from the following Web site:
ftp://ftp.microsoft.com/bussys/IIS/iis-public/iis40/SDK/iwamreg.h


REFERENCES

Microsoft Internet Information Server 4.0 Documentation

Additional query words:

Keywords : kbfile kbDSupport kbiis400
Version : winnt:4.0
Platform : winnt
Issue type : kbinfo


Last Reviewed: December 8, 1999
© 2000 Microsoft Corporation. All rights reserved. Terms of Use.