Export (0) Print
Expand All

ManagementObjectSearcher Constructor (ManagementScope, ObjectQuery, EnumerationOptions)

Initializes a new instance of the ManagementObjectSearcher class to be used to invoke the specified query in the specified scope, with the specified options.

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

Public Sub New ( _
	scope As ManagementScope, _
	query As ObjectQuery, _
	options As EnumerationOptions _


Type: System.Management.ManagementScope

A ManagementScope specifying the scope of the query.

Type: System.Management.ObjectQuery

An ObjectQuery specifying the query to be invoked.

Type: System.Management.EnumerationOptions

An EnumerationOptions specifying additional options to be used for the query.

.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 ManagementObjectSearcher class with a specific query, scope, and enumeration options.

Imports System
Imports System.Management

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

        Dim scope As New ManagementScope("root\MyApp")
        Dim q As New SelectQuery("SELECT * FROM Win32_LogicalDisk")
        Dim o As New EnumerationOptions( _
            Nothing, System.TimeSpan.MaxValue, 1, _
            True, False, True, True, False, _
            True, True)
        Dim s As New ManagementObjectSearcher(scope, q, o)

        For Each disk As ManagementObject In s.Get()
            'show the disk instance

    End Function 'Main
End Class 'Sample

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft