ManagementObject Constructor (ManagementScope, ManagementPath, ObjectGetOptions)
Initializes a new instance of the ManagementObject class bound to the specified WMI path that includes the specified options.
Assembly: System.Management (in System.Management.dll)
'Declaration Public Sub New ( _ scope As ManagementScope, _ path As ManagementPath, _ options As ObjectGetOptions _ )
- Type: System.Management.ManagementScope
A ManagementScope representing the scope in which the WMI object resides. In this version, scopes can only be WMI namespaces.
- Type: System.Management.ManagementPath
A ManagementPath representing the WMI path to the manageable 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.
Imports System Imports System.Management Class Sample_ManagementClass Public Overloads Shared Function Main( _ ByVal args() As String) As Integer Dim s As New ManagementScope( _ "\\MyMachine\root\cimv2") Dim p As New ManagementPath( _ "Win32_Service") ' Set options for no context info, ' but requests amended qualifiers ' to be contained in the object Dim opt As ObjectGetOptions opt = New ObjectGetOptions( _ Nothing, TimeSpan.MaxValue, True) Dim o As ManagementObject o = New ManagementObject(s, p, opt) Console.WriteLine(o.Qualifiers("Description").Value) Return 0 End Function End Class
- 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.
Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.