Bewerken

Share via


ManagementObject.Path Property

Definition

Gets or sets the object's WMI path.

public:
 virtual property System::Management::ManagementPath ^ Path { System::Management::ManagementPath ^ get(); void set(System::Management::ManagementPath ^ value); };
public virtual System.Management.ManagementPath Path { get; set; }
member this.Path : System.Management.ManagementPath with get, set
Public Overridable Property Path As ManagementPath

Property Value

A ManagementPath representing the object's path.

Examples

The following example initializes a new instance of the ManagementObject class with the default namespace, and then changes the WMI path of the ManagementObject.

using System;
using System.Management;
public class Sample
{
    public static void Main()
    {
        ManagementObject o = new ManagementObject();

        // Specify the WMI path to which
        // this object should be bound to
        o.Path = new ManagementPath(
            "Win32_Process.Name='calc.exe'");
    }
}
Imports System.Management
Public Class Sample

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

        Dim o As New ManagementObject

        ' Specify the WMI path to which 
        ' this object should be bound to
        o.Path = New ManagementPath( _
            "Win32_Process.Name=""calc.exe""")

        Return 0
    End Function
End Class

Remarks

Changing the property after the management object has been bound to a WMI object in a particular namespace results in releasing the original WMI object. This causes the management object to be rebound to the new object specified by the new path properties and scope values.

The rebinding is performed in a "lazy" manner, that is, only when a requested value requires the management object to be bound to the WMI object. Changes can be made to more than just the property before attempting to rebind (for example, modifying the scope and path properties simultaneously).

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

Applies to