共用方式為


VirtualDirectory.RevertToParent 方法2

將虛擬目錄的組態值或值還原為預設值。

語法

VirtualDirectory.RevertToParent(PropertyName)  
VirtualDirectory.RevertToParent(PropertyName);  

參數

名稱 描述
PropertyName 選擇性 string 值,其中包含要還原為 VirtualDirectoryElementDefaults 類別所指定之預設的虛擬目錄屬性名稱,該類別會公開為 VirtualDirectoryDefaultsApplication 類別上的 屬性。

傳回值

這個方法不會傳回值。

備註

當您呼叫不含參數的方法時 RevertToParent ,將會移除虛擬目錄的所有自訂群組態值。 如果這不是您想要的行為,請使用方法的參數化呼叫來還原特定屬性。

範例

下列範例會將 AllowSubDirConfig 虛擬目錄的 MyVDir 屬性從目前的 值 false 還原為其預設值 true

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject( _  
    "winmgmts:root\WebAdministration")  
  
' Assign the virtual directory instances to a variable.  
Set oVDirs = oWebAdmin.InstancesOf("VirtualDirectory")  
  
' Retrieve the MyVDir virtual directory.  
For Each oVDir In oVDirs  
    If oVDir.Path = "/MyVDir" Then  
  
        ' Display the virtual directory path.  
        WScript.Echo "Virtual Path: " & oVDir.Path  
  
        ' Display the current value.  
        WScript.Echo "AllowSubDirConfig before revert: " & _  
                oVDir.AllowSubDirConfig      
  
        ' Revert the AllowSubDirConfig property.  
        oVdir.RevertToParent("AllowSubDirConfig")  
  
        ' Refresh the oVdir object variable.  
        oVdir.Refresh_  
  
        ' Display the changed value.  
        WScript.Echo "AllowSubDirConfig after revert: " & _  
                oVDir.AllowSubDirConfig   
  
        ' Exit the loop.  
        Exit For   
    End If  
Next  
  
' Output:  
' Virtual Path: /MyVDir  
' AllowSubDirConfig before revert: False  
' AllowSubDirConfig after revert: True  
  

規格需求

類型 描述
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

另請參閱

應用程式類別
VirtualDirectory 類別
VirtualDirectoryElementDefaults 類別