The following example assigns the Northwind application to an application pool named NewAppPool.
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")
' Retrieve the application and display its Web site name and path.
Set oApp = oWebAdmin.Get(_
"Application.SiteName='Default Web Site',Path='/Northwind'")
WScript.Echo "Web site and path: '" & oApp.SiteName & oApp.Path & "'"
WScript.Echo "Old application pool: " & oApp. ApplicationPool
' Specify a new application pool name and save it.
' Note that the name is case-sensitive.
oApp.ApplicationPool = "NewAppPool"
oApp.Put_
' Display the new application pool name.
WScript.Echo "New application pool: " & oApp.ApplicationPool Note: |
|---|
The name of the application pool is case-sensitive.
|
IIS does not verify whether the specified application pool actually exists. If the application pool does not exist, the user receives an HTTP error 403.18 with the message "The specified request cannot be executed in the application pool that is configured for this resource on the Web server."
To set the default application pool for all the applications in a Web site, use the ApplicationDefaults property of the Site class.