ManagementScope 클래스

정의

관리 작업의 범위(네임스페이스)를 나타냅니다.

public ref class ManagementScope : ICloneable
public class ManagementScope : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Management.ManagementScopeConverter))]
public class ManagementScope : ICloneable
type ManagementScope = class
    interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Management.ManagementScopeConverter))>]
type ManagementScope = class
    interface ICloneable
Public Class ManagementScope
Implements ICloneable
상속
ManagementScope
특성
구현

예제

다음 예제에서는 특정 경로를 사용하여 새 ManagementScope 를 초기화한 다음, 범위 개체를 WMI 네임스페이스에 연결합니다. 이 예제에서는 원격 컴퓨터의 네임스페이스에 연결합니다.

using System;
using System.Management;
public class RemoteConnect
{
    public static void Main()
    {
        /*// Build an options object for the remote connection
        //   if you plan to connect to the remote
        //   computer with a different user name
        //   and password than the one you are currently using

             ConnectionOptions options =
                 new ConnectionOptions();

             // and then set the options.Username and
             // options.Password properties to the correct values
             // and also set
             // options.Authority = "ntlmdomain:DOMAIN";
             // and replace DOMAIN with the remote computer's
             // domain.  You can also use Kerberos instead
             // of ntlmdomain.
        */

        // Make a connection to a remote computer.
        // Replace the "FullComputerName" section of the
        // string "\\\\FullComputerName\\root\\cimv2" with
        // the full computer name or IP address of the
        // remote computer.
        ManagementScope scope =
            new ManagementScope(
            "\\\\FullComputerName\\root\\cimv2");
        scope.Connect();

        // Use this code if you are connecting with a
        // different user name and password:
        //
        // ManagementScope scope =
        //    new ManagementScope(
        //        "\\\\FullComputerName\\root\\cimv2", options);
        // scope.Connect();

        //Query system for Operating System information
        ObjectQuery query = new ObjectQuery(
            "SELECT * FROM Win32_OperatingSystem");
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(scope,query);

        ManagementObjectCollection queryCollection = searcher.Get();
        foreach ( ManagementObject m in queryCollection)
        {
            // Display the remote computer information
            Console.WriteLine("Computer Name : {0}",
                m["csname"]);
            Console.WriteLine("Windows Directory : {0}",
                m["WindowsDirectory"]);
            Console.WriteLine("Operating System: {0}",
                m["Caption"]);
            Console.WriteLine("Version: {0}", m["Version"]);
            Console.WriteLine("Manufacturer : {0}",
                m["Manufacturer"]);
        }
    }
}
Imports System.Management
Public Class RemoteConnect

    Public Overloads Shared Function Main( _
    ByVal args() As String) As Integer


        ' Build an options object for the remote connection
        ' if you plan to connect to the remote
        ' computer with a different user name
        ' and password than the one you are currently using

        ' Dim options As ConnectionOptions 
        ' options = new ConnectionOptions()

        ' Then set the options.Username and 
        ' options.Password properties to the correct values
        ' and also set 
        ' options.Authority = "ntlmdomain:DOMAIN"
        ' and replace DOMAIN with the remote computer's
        ' domain.  You can also use Kerberos instead
        ' of ntlmdomain.


        ' Make a connection to a remote computer.
        ' Replace the "FullComputerName" section of the
        ' string "\\FullComputerName\root\cimv2" with
        ' the full computer name or IP address of the
        ' remote computer.
        Dim scope As ManagementScope
        scope = New ManagementScope( _
            "\\FullComputerName\root\cimv2")
        scope.Connect()

        ' Use this code if you are connecting with a 
        ' different user name and password:
        '
        ' Dim scope As ManagementScope
        ' scope = New ManagementScope( _
        '     "\\FullComputerName\root\cimv2", options)
        ' scope.Connect()

        ' Query system for Operating System information
        Dim query As ObjectQuery
        query = New ObjectQuery( _
            "SELECT * FROM Win32_OperatingSystem")
        Dim searcher As ManagementObjectSearcher
        searcher = _
            New ManagementObjectSearcher(scope, query)

        Dim queryCollection As ManagementObjectCollection
        queryCollection = searcher.Get()

        Dim m As ManagementObject
        For Each m In queryCollection
            ' Display the remote computer information
            Console.WriteLine("Computer Name : {0}", _
                m("csname"))
            Console.WriteLine("Windows Directory : {0}", _
                m("WindowsDirectory"))
            Console.WriteLine("Operating System: {0}", _
                m("Caption"))
            Console.WriteLine("Version: {0}", m("Version"))
            Console.WriteLine("Manufacturer : {0}", _
                m("Manufacturer"))
        Next

        Return 0
    End Function
End Class

생성자

ManagementScope()

기본값으로 ManagementScope 클래스의 새 인스턴스를 초기화합니다. 이는 매개 변수가 없는 생성자입니다.

ManagementScope(ManagementPath)

지정된 범위 경로를 나타내는 ManagementScope 클래스의 새 인스턴스를 초기화합니다.

ManagementScope(ManagementPath, ConnectionOptions)

지정된 옵션을 사용하여 지정된 범위 경로를 나타내는 ManagementScope 클래스의 새 인스턴스를 초기화합니다.

ManagementScope(String)

지정된 범위 경로를 나타내는 ManagementScope 클래스의 새 인스턴스를 초기화합니다.

ManagementScope(String, ConnectionOptions)

지정된 옵션을 사용하여 지정된 범위 경로를 나타내는 ManagementScope 클래스의 새 인스턴스를 초기화합니다.

속성

IsConnected

ManagementScope가 현재 WMI 서버와 네임스페이스에 바인딩되어 있는지 여부를 나타내는 값을 가져옵니다.

Options

WMI 연결에 대한 옵션을 가져오거나 설정합니다.

Path

ManagementScope에 대한 경로를 가져오거나 설정합니다.

메서드

Clone()

개체의 복사본을 반환합니다.

Connect()

ManagementScope를 실제 WMI 범위에 연결합니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

명시적 인터페이스 구현

ICloneable.Clone()

현재 인스턴스의 복사본인 새 개체를 만듭니다.

적용 대상