ManagementPath Class
TOC
Collapse the table of content
Expand the table of content

ManagementPath Class

 

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

Namespace:   System.Management
Assembly:  System.Management (in System.Management.dll)

System.Object
  System.Management.ManagementPath

public class ManagementPath : ICloneable

NameDescription
System_CAPS_pubmethodManagementPath()

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

System_CAPS_pubmethodManagementPath(String)

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

NameDescription
System_CAPS_pubpropertyClassName

Gets or sets the class portion of the path.

System_CAPS_pubpropertySystem_CAPS_staticDefaultPath

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.

System_CAPS_pubpropertyIsClass

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

System_CAPS_pubpropertyIsInstance

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

System_CAPS_pubpropertyIsSingleton

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

System_CAPS_pubpropertyNamespacePath

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

System_CAPS_pubpropertyPath

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

System_CAPS_pubpropertyRelativePath

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

System_CAPS_pubpropertyServer

Gets or sets the server part of the path.

NameDescription
System_CAPS_pubmethodClone()

Returns a copy of the ManagementPath.

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodSetAsClass()

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

System_CAPS_pubmethodSetAsSingleton()

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.

System_CAPS_pubmethodToString()

Returns the full object path as the string representation. (Overrides Object.ToString().)

NameDescription
System_CAPS_pubinterfaceSystem_CAPS_privmethodICloneable.Clone()

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

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" +
            "\\cimv2:Win32_LogicalDisk.DeviceID=\"C:\"");

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

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

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

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

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

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

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

    }
}

.NET Framework
Available since 1.1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show:
© 2016 Microsoft