Application.Create Method [IIS 7 and higher]
Creates a Web application.
Syntax
oWebAdmin.Get("Application").Create(
ApplicationPath,
SiteName,
PhysicalPath
)
var app = webAdmin.Get("Application").Create(
ApplicationPath,
SiteName,
PhysicalPath
);
Parameters
Name |
Description |
---|---|
ApplicationPath |
A required string value that contains the virtual path for the new application. The path cannot be changed after the application is created. |
PhysicalPath |
An optional string value that contains the physical path for the application's root virtual directory. |
SiteName |
A required string value that contains the name of the Web site on which the application will be created. |
Return Value
This method does not return a value.
Remarks
If the PhysicalPath parameter contains a nonexistent directory, the Create method will not automatically create the directory specified by PhysicalPath.
Create replaces previous methods of creating IIS applications. To create an application in IIS 6.0, you first created a new virtual directory by calling SpawnInstance_ on IIsWebVirtualDir and then called the IIsWebVirtualDir.AppCreate2, IIsWebVirtualDir.AppCreate, or IIsWebVirtualDir.AppCreate3 method.
Note
You cannot use Application.SpawnInstance_ and Application.Put_ to create a new application. A new application must have at least an application path and site name, and you can specify these only through the Create method's ApplicationPath and SiteName parameters.
Example
The following example creates a new Web application.
Note
Because the Create method is static, it must be called on the application class.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Define the Path, SiteName, and PhysicalPath parameters.
strAppPath = "/NewApp"
strSiteName = "Default Web Site"
strPhysPath = "D:\inetpub\NewApp"
' Create the new application.
oWebAdmin.Get("Application").Create strAppPath, strSiteName, strPhysPath
Requirements
Type |
Description |
---|---|
Client |
Requires IIS 7 on Windows Vista. |
Server |
Requires IIS 7 on Windows Server 2008. |
Product |
IIS 7 |
MOF file |
WebAdministration.mof |