Export (0) Print
Expand All

ManagementObject Constructor (ManagementScope, ManagementPath, ObjectGetOptions)

Initializes a new instance of the ManagementObject class bound to the specified WMI path that includes the specified options.

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

public ManagementObject (
	ManagementScope scope,
	ManagementPath path,
	ObjectGetOptions options
)
public ManagementObject (
	ManagementScope scope, 
	ManagementPath path, 
	ObjectGetOptions options
)
public function ManagementObject (
	scope : ManagementScope, 
	path : ManagementPath, 
	options : ObjectGetOptions
)

Parameters

scope

A ManagementScope representing the scope in which the WMI object resides. In this version, scopes can only be WMI namespaces.

path

A ManagementPath representing the WMI path to the manageable object.

options

An ObjectGetOptions specifying additional options for getting the object.

Because WMI paths can be relative or full, a conflict between the scope and the path specified may arise. However, if a scope is specified and a relative WMI path is specified, then there is no conflict. The following are some possible conflicts:

If a scope is not specified and a relative WMI path is specified, then the scope will default to the local machine's DefaultPath.

If a scope is not specified and a full WMI path is specified, then the scope will be inferred from the scope portion of the full path. For example, the full WMI path: \\MyMachine\root\MyNamespace:MyClass.Name='abc' will represent the WMI object 'MyClass.Name='abc'" in the scope '\\MyMachine\root\MyNamespace'.

If a scope is specified and a full WMI path is specified, then the scope will override the scope portion of the full path. For example, if the following scope was specified: \\MyMachine\root\MyScope, and the following full path was specified: \\MyMachine\root\MyNamespace:MyClass.Name='abc', then look for the following object: \\MyMachine\root\MyScope:MyClass.Name= 'abc' (the scope part of the full path is ignored).

.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.

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) 
    {
        ManagementScope s = new ManagementScope(
            "\\\\MyMachine\\root\\cimv2");
        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, TimeSpan.MaxValue, true); 

        ManagementObject o = new ManagementObject(s, p, opt);

        Console.WriteLine(o.Qualifiers["Description"].Value);

        return 0;
    }
}

  • Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see .

Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see System Requirements.

.NET Framework

Supported in: 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2015 Microsoft