ManagementObject Constructor (ManagementPath, ObjectGetOptions)


Initializes a new instance of the ManagementObject class bound to the specified WMI path, including the specified additional options.

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

public ManagementObject(
	ManagementPath path,
	ObjectGetOptions options


Type: System.Management.ManagementPath

A ManagementPath containing the WMI path.

Type: System.Management.ObjectGetOptions

An ObjectGetOptions containing additional options for binding to the WMI object. This parameter could be null if default options are to be used.

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.

The following example initializes a new instance of the ManagementObject class that is bound to a specific WMI path.

using System;
using System.Management;

class Sample
    public static int Main(string[] args) 
        ManagementPath p = 
            new ManagementPath("Win32_Service");

        // Set options for no context info
        // but requests amended qualifiers 
        // to be contained in the object
        ObjectGetOptions opt = 
            new ObjectGetOptions(
            null, System.TimeSpan.MaxValue, true);    

        ManagementClass c = 
            new ManagementClass(p, opt);


        return 0;

.NET Framework
Available since 1.1
Return to top