다음을 통해 공유


ConfigurationSectionWithCollection.Remove 메서드

구성 섹션의 컬렉션에서 지정된 요소를 제거합니다.

구문

ConfigurationSectionWithCollection.Remove collectionName, element;  
ConfigurationSectionWithCollection.Remove collectionName, element  

매개 변수

이름 정의
collectionName string 제거할 요소가 있는 컬렉션의 이름을 지정하는 값입니다.
element 제거할 요소를 포함하는 CollectionElement 개체입니다.

반환 값

이 메서드는 값을 반환하지 않습니다.

예제

다음 예제에서는 기본 웹 사이트에 대한 처리기의 이름을 표시하고, "CGI-exe"라는 처리기 요소가 있는 경우 제거한 다음, 처리기 이름을 다시 나열합니다. 이 코드로 인해 기본 웹 사이트의 Web.config 파일 섹션에 다음 XML이 추가 <system.webServer> 됩니다.

<handlers>

<remove name="CGI-exe" />

</handlers>

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the default Web site.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
  
' Get the handlers section.  
oSite.GetSection "HandlersSection", oHandlersSection  
  
' Display the current handler names.  
Wscript.Echo "---[Current Handler List]---"  
Call DisplayHandlerNames  
  
' Remove the CGI-exe handler by matching its name.  
For Each oHandler In oHandlersSection.Handlers  
     If oHandler.Name = "CGI-exe" Then  
        oHandlersSection.Remove "Handlers", oHandler  
    End If   
Next  
  
' Refresh the oHandlersSection object so that its contents will  
' reflect the updated configuration.  
oHandlersSection.Refresh_      
  
' List the handler names again to show the change.  
Wscript.Echo "---[New Handler List]---"  
Call DisplayHandlerNames  
  
' Provide a subroutine to display handler names.  
Sub DisplayHandlerNames  
    For Each oHandler In oHandlersSection.Handlers  
        WScript.Echo "Handler Name: " & oHandler.Name  
    Next  
    Wscript.Echo  
End Sub  
  

참고 메서드를 호출하면 Remove_ 기본 구성 저장소가 업데이트되지만 메모리에서 실행되는 개체는 업데이트되지 않습니다 oHandlersSection . 에서 메서드 oHandlersSectionRefresh_ 호출하면 나중에 동일한 스크립트에서 사용해야 하는 경우 해당 데이터가 정확한지 확인할 수 있습니다.

요구 사항

형식 Description
클라이언트 - 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

참고 항목

ConfigurationSectionWithCollection 클래스
HandlerAction 클래스
HandlersSection 클래스