VirtualDirectory.RevertToParent Method2

Reverts a virtual directory's configuration value or values to the default.

Syntax

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

Parameters

Name Description
PropertyName An optional string value that contains the name of a virtual directory property to revert to the default specified by the VirtualDirectoryElementDefaults class that is exposed as the VirtualDirectoryDefaults property on the Application class.

Return Value

This method does not return a value.

Remarks

When you call the RevertToParent method without parameters, all custom configuration values for the virtual directory will be removed. If this is not the behavior you want, revert specific properties by using parameterized calls to the method.

Example

The following example reverts the AllowSubDirConfig property of the MyVDir virtual directory from its current value of false to its default value of 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  
  

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

Application Class
VirtualDirectory Class
VirtualDirectoryElementDefaults Class