ManagementPath ManagementPath ManagementPath ManagementPath Class


Provides a wrapper for parsing and building paths to WMI objects.

public ref class ManagementPath : ICloneable
public class ManagementPath : ICloneable
type ManagementPath = class
    interface ICloneable
Public Class ManagementPath
Implements ICloneable


The following example demonstrates how the ManagementPath class parses a path to a WMI object. The path that is parsed in the example is a path to an instance of a class.

using System;
using System.Management;

public class Sample 
    public static void Main() 

        // Get the WMI class path
        ManagementPath p = 
            new ManagementPath(
            "\\\\ComputerName\\root" +

        Console.WriteLine("IsClass: " +
        // Should be False (because it is an instance)

        Console.WriteLine("IsInstance: " +
        // Should be True

        Console.WriteLine("ClassName: " +
        // Should be "Win32_LogicalDisk"

        Console.WriteLine("NamespacePath: " +
        // Should be "ComputerName\cimv2"

        Console.WriteLine("Server: " + 
        // Should be "ComputerName"

        Console.WriteLine("Path: " +
        // Should be "ComputerName\root\cimv2:
        // Win32_LogicalDisk.DeviceId="C:""

        Console.WriteLine("RelativePath: " +
        // Should be "Win32_LogicalDisk.DeviceID="C:""

Imports System
Imports System.Management

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

        ' Get the WMI class path
        Dim p As ManagementPath = _
            New ManagementPath( _
            "\\ComputerName\root" & _

        Console.WriteLine("IsClass: " & _
        ' Should be False (because it is an instance)

        Console.WriteLine("IsInstance: " & _
        ' Should be True

        Console.WriteLine("ClassName: " & _
        ' Should be "Win32_LogicalDisk"

        Console.WriteLine("NamespacePath: " & _
        ' Should be "ComputerName\cimv2"

        Console.WriteLine("Server: " & _
        ' Should be "ComputerName"

        Console.WriteLine("Path: " & _
        ' Should be "ComputerName\root\cimv2:
        ' Win32_LogicalDisk.DeviceId="C:""

        Console.WriteLine("RelativePath: " & _
        ' Should be "Win32_LogicalDisk.DeviceID="C:""

    End Function
End Class


ManagementPath() ManagementPath() ManagementPath() ManagementPath()

Initializes a new instance of the ManagementPath class that is empty. This is the default constructor.

ManagementPath(String) ManagementPath(String) ManagementPath(String) ManagementPath(String)

Initializes a new instance of the ManagementPath class for the given path.


ClassName ClassName ClassName ClassName

Gets or sets the class portion of the path.

DefaultPath DefaultPath DefaultPath DefaultPath

Gets or sets the default scope path used when no scope is specified. The default scope is \\.\root\cimv2, and can be changed by setting this property.

IsClass IsClass IsClass IsClass

Gets or sets a value indicating whether this is a class path.

IsInstance IsInstance IsInstance IsInstance

Gets or sets a value indicating whether this is an instance path.

IsSingleton IsSingleton IsSingleton IsSingleton

Gets or sets a value indicating whether this is a singleton instance path.

NamespacePath NamespacePath NamespacePath NamespacePath

Gets or sets the namespace part of the path. Note that this does not include the server name, which can be retrieved separately.

Path Path Path Path

Gets or sets the string representation of the full path in the object.

RelativePath RelativePath RelativePath RelativePath

Gets or sets the relative path: class name and keys only.

Server Server Server Server

Gets or sets the server part of the path.


Clone() Clone() Clone() Clone()

Returns a copy of the ManagementPath.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetAsClass() SetAsClass() SetAsClass() SetAsClass()

Sets the path as a new class path. This means that the path must have a class name but not key values.

SetAsSingleton() SetAsSingleton() SetAsSingleton() SetAsSingleton()

Sets the path as a new singleton object path. This means that it is a path to an instance but there are no key values.

ToString() ToString() ToString() ToString()

Returns the full object path as the string representation.

Explicit Interface Implementations

ICloneable.Clone() ICloneable.Clone() ICloneable.Clone() ICloneable.Clone()

Creates a new object that is a copy of the current instance.

Applies to