將應用程式的組態值或值還原為預設值。
語法
Application.RevertToParent(PropertyName)
Application.RevertToParent(PropertyName);
參數
| 名稱 | 描述 |
|---|---|
PropertyName |
選擇性 string 值,其中包含要還原為 ApplicationElementDefaults 類別所指定之應用程式屬性的名稱,而 ApplicationElementDefaults 類別 會公開為 ApplicationDefaults 父 站 台類別上的 屬性。 要還原的屬性可以是巢狀 (,例如「VirtualDirectoryDefaults.PhysicalPath」) 。 |
傳回值
這個方法不會傳回值。
備註
當您呼叫 RevertToParent 不含參數時,將會移除ApplicationHost.config檔案中應用程式的所有設定。 如果這不是您想要的行為,請使用方法的個別參數化呼叫來還原特定屬性。
範例
下列範例會將預設網站 MyApp 的應用程式集區名稱從 「MyAppPool」 還原為 「DefaultAppPool」。
' Connect to the WMI WebAdministration namespace.
Set oWebAdmin = GetObject( _
"winmgmts:root\WebAdministration")
' Retrieve the MyApp application from the default Web site.
Set oApp = oWebAdmin.Get( _
"Application.SiteName='Default Web Site',Path='/MyApp'")
' Display the site name, path, and application pool.
WScript.Echo "Web site name: " & oApp.SiteName
WScript.Echo "Application path: " & oApp.Path
Wscript.Echo "ApplicationPool: " & oApp.ApplicationPool
' Revert the MyApp application pool to the application pool
' specified by the parent site's ApplicationDefaults property.
oApp.RevertToParent("ApplicationPool")
' Update the contents of the application object variable.
oApp.Refresh_
' Display the change.
Wscript.Echo "ApplicationPool after revert: " & _
oApp.ApplicationPool
' Example output:
' Web site name: Default Web Site
' Application path: /MyApp
' ApplicationPool: MyAppPool
' ApplicationPool after revert: DefaultAppPool
規格需求
| 類型 | 描述 |
|---|---|
| Client | - Windows Vista 上的 IIS 7.0 - Windows 7 上的 IIS 7.5 - Windows 8 上的 IIS 8.0 - Windows 10上的 IIS 10.0 |
| 伺服器 | - Windows Server 2008 上的 IIS 7.0 - Windows Server 2008 R2 上的 IIS 7.5 - Windows Server 2012 上的 IIS 8.0 - Windows Server 2012 R2 上的 IIS 8.5 - Windows Server 2016上的 IIS 10.0 |
| 產品 | - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0 |
| MOF 檔案 | WebAdministration.mof |